Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:43:21+00:00 2026-06-12T05:43:21+00:00

I have a java program and I want to log in /var/log/messages file on

  • 0

I have a java program and I want to log in /var/log/messages file on fedora machine. I am usin log4j SyslogAppender but its not working.

my log4j properties file contains

# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE, SYSLOG
#log4j.rootCategory=INFO, CONSOLE, LOGFILE

# Set the enterprise logger priority to DEBUG
log4j.logger.com.locaid=INFO, CONSOLE, LOGFILE, SYSLOG

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=/home/dev/app.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=[%d{dd/MM/y HH:mm:ss}][%t][%1p] %c - %m%n

log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.syslogHost=localhost
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.conversionPattern=%d{ISO8601} %-5p [%t] %c{2} %x - %m%n
log4j.appender.SYSLOG.Facility=LOCAL1
log4j.appender.SYSLOG.Threshold=debug
log4j.appender.SYSLOG.FacilityPrinting=true

in /etc/rsyslog.conf i have

local1.*      /var/log/app.log

in /etc/sysconfig/rsyslog have

SYSLOGD_OPTIONS="-r -m 0 -c 4"

On restarting rsyslog service app.log file is created but no logs are being appended. I have also tried with default USER facility its not working although logger -p LOCAL1.info cmd is working and appending log to app.log. Need help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:43:23+00:00Added an answer on June 12, 2026 at 5:43 am

    I can’t see anything wrong at the log4j end, but my /etc/default/rsyslog (on Ubuntu) says

    # Options for rsyslogd
    # -m 0 disables 'MARK' messages (deprecated, only used in compat mode < 3)
    # -r enables logging from remote machines (deprecated, only used in compat mode < 3)
    # -x disables DNS lookups on messages received with -r
    # -c compatibility mode
    # See rsyslogd(8) for more details
    

    which suggests that -r and -m 0 won’t work in combination with -c 4. Instead of trying to set remote access here, you should edit your /etc/rsyslogd.conf and add (or uncomment)

    $ModLoad imudp
    $UDPServerRun 514
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program which i have myself written in java, but I want
I have a Java program that reads lines from text file. I want to
I have two strings in a java program, which I want to mix in
I have a Java program with Maven managing its dependencies. One of those dependency
I have a java program and want to generate javadoc for classes/interfaces. However, I
I have a Java program and I want to send a command from my
I have my java program connected to postgresql. I want to retrieve the error
I have a Java program which its main method (in the main class) expects
I have a basic Java program with output of hello world. What I want
I have a C++ application and a Java application that need to log messages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.