I'm having the same issue described here: Log4j Warning while initializing?
My application has a log4j.properties that allows me to configure log4j.rootLogger=INFO, stdout correctly. However I still see:
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
When running the application.
My log4j.properties currently reads:
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c:%L - %m%n
#log4j.category.org.springframework=DEBUG,stdout
I've also tried adding the properties file to my config via:
#PropertySource(value= {
"classpath:/log4j.properties",
"classpath:/application.properties"
})
How can I make this error go away? I can toggle between DEBUG and INFO just fine via this file, so I know it's being read.
You can make this error go away by adding the line
log4j.logger.org.jboss.logging=INFO, stdout
to your log4j.properties.
I don't know why, but it seems like something sets the additivity of org.jboss.logging to false, causing it to ignore the root appender(s). So you can either find that magical spot or you add the the line above.
Related
I have recently added Log4j in my project and all the logs are printing as expected.
Now I have added the timestamp in the log4j.properties file and server-generated logs are printing with the timestamp but which statements I am printing from Logger.info() and Logger.error() it is not printing with the timestamp. This is how my log4j.properties look like:
logFileLoc = ${catalina.base}/logs/
log4j.rootLogger=INFO, stdout, fileAppender
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}: [%-5p] %c{1}:%L - %m%n
# Redirect Log Messages To A Debug Log File, Support File Rolling !!
log4j.appender.fileAppender=org.apache.log4j.RollingFileAppender
log4j.appender.fileAppender.File=${logFileLoc}/catalina.out
log4j.appender.fileAppender.MaxFileSize=50MB
log4j.appender.fileAppender.MaxBackupIndex=10
log4j.appender.fileAppender.Append=true
log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.fileAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}: [%-5p] %c{1}:%L - %m%n
Whenever I try something like this in my code:
LOGGER.debug("creating HomePage");
This is what I see in my log file:
creating HomePage
Can anyone please suggest how can I print the timestamp in LOGGER statements? It will be highly appreciable.
I checked your configuration with log4j 1.2.17 and everything works correctly.
I think you have other log4j config file in classpath or you are using system variables(like log4j.defaultInitOverride or some others) which have impact on log4j configuration.
I recommend debugging log4j initialization in static block of the LogManager class and then you will see from which place log4j is loading configuration.
if I'm wrong, please provide code for reproducing your issue.
I am using the log4j.properties in My Selenium Package.
Every Time I run the Module the below 3 Lines are always been added in the Console and the Applications.log file.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
For Reference, below is the log4j.properties Code:
#Application Logs
log4j.logger.devpinoyLogger = DEBUG,dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.maxFileSize= 5000KB
log4j.appender.dest1.maxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/YYYY HH:mm:ss} %m%n
log4j.appender.dest1.File=D:\\Automation\\src\\Logs\\Application.log
#do not append the old file .Create a new log File everytime
log4j.appender.dest1.Append=false
Please let me know what needs to be change in order to remove the 3 lines of Warnings from the console output and Application logs.
Please include the following snippet to your code:
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
Hope this helps!
This will resolve your errors and the message appears in the console:
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.Jdk14Logger");
I'm running Mac OS X 10. I just did brew install zookeeper.
Then I created /usr/local/etc/zookeeper/zoo.cfg based on /usr/local/etc/zookeeper/zoo_sample.cfg.
Then zkServer start works just fine.
But, when trying to connect to Zookeeper from Clojure, which uses the Zookeeper Java client, I get this error:
log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
My log4j.properties file:
log4j.rootCategory=WARN, zklog
log4j.appender.zklog = org.apache.log4j.FileAppender
log4j.appender.zklog.File = /usr/local/var/log/zookeeper/zookeeper.log
log4j.appender.zklog.Append = true
log4j.appender.zklog.layout = org.apache.log4j.PatternLayout
log4j.appender.zklog.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n
So, my questions are:
What is a reasonable log4j configuration for my situation?
What could homebrew do, out of the box, to prevent this warning from happening?
To be clear, there are two log4j.properties files involved. One is created by Homebrew and gets written to /usr/local/etc/zookeeper/log4j.properties. This file is not the cause of the error message above.
The other log4j.properties file is particular to your (my) application. So, to answer part 1 of the question, create a log4j.properties file on the classpath of the Clojure app, such as in the src directory.
log4j.rootLogger=WARN, A1
log4j.logger.user=DEBUG
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d %-5p %c: %m%n
log4j.logger.org.apache.zookeeper=WARN
I built this by starting with https://github.com/clojure/tools.logging and adding the last line.
To answer part 2, Homebrew does not and should not have anything to do with how a Clojure application sets up its logging.
I have created a very simple application, where I am trying to use the Log4J, but my application is not logging any log.
Can anyone please tell me how can I debug the same as my log4j started or not?
I have kept the file in classes folder of WEB-INF/classes
Thanks
following is my log4j.properties
log4j.rootLogger=debug, stdout, ABC
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.ABC=org.apache.log4j.RollingFileAppender
log4j.appender.ABC.File=D://abc//dams_workflow_application.log
log4j.appender.ABC.MaxFileSize=3000KB
# Keep one backup file
log4j.appender.ABC.MaxBackupIndex=10
log4j.appender.ABC.layout=org.apache.log4j.PatternLayout
log4j.appender.ABC.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
following is the sample line for using log 4j..
Logger log = Logger.getLogger("ABC");
log.info("my message");
If you're writing a web application, you can view the Log4J Default Initialization Under Tomcat. Even it states Tomcat, the same applies in other Containers/Web application servers.
Console will print this if log4j is not started :
log4j:WARN No log4j configuration information found.
log4j:WARN Changed non-configured level from DEBUG to ERROR.
log4j:WARN The log4j system is not properly configured!
You could have a look at Log4j - Looking for a good 'Getting started' tutorial or blog
to get started.
Regards,
Stéphane
Make sure the log4j jar is in the lib directory for your webapp or in the lib directory in tomcat.
Log4j doesn't seem to work properly for me unless i put the log4j properties file in the default package in the webapp's source directory within the project.
All of my log4j properties files typically look similar to the following
# Define a logger called "processLog" using the FileAppender implementation of the
# Log interface
log4j.appender.processLog=org.apache.log4j.DailyRollingFileAppender
log4j.appender.processLog.File.DateFormat='.'yyyy-ww
# Define the output location
log4j.appender.processLog.File=C:/logs/myapp.log
# Define what the output is going to look like for your log
log4j.appender.processLog.layout=org.apache.log4j.PatternLayout
log4j.appender.processLog.layout.ConversionPattern=%d{yyyy-MM-dd hh:mm a} %5p %c{1}: Line#%L - %m%n
# log4j.rootLogger specifies the default logging level and output location.
# The first parameter is the level (debug > info > warn > error > fatal).
log4j.rootLogger=INFO, processLog
That's how I do it anyway. There may be a better way but this one always works for me.
My log4j.properties file -
log4j.rootLogger=INFO, stdout
# =============== console output appender =====================
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %5p: [%c{1}] %m%n
# =================== common logging =========================
# The log level for all classes that are not configured below.
log4j.logger.petascope=INFO
log4j.logger.petascope.wcps=DEBUG
log4j.logger.petascope.wcst=DEBUG
log4j.logger.petascope.wcs=DEBUG
log4j.logger.petascope.wcs2=TRACE
I want to display even DEBUG and TRACE messages on stdout, so I changed the following line
log4j.rootLogger=TRACE, stdout
But I don't see any changes when I view the logs echoes on Tomcat Console, I still see only INFO, WARN ... messages.
Well, even if you have your root logger as TRACE, your log4j.logger.petascope (pointing to INFO) will override the default root logger's TRACE for petascope.* packages, which is the reason you are not seeing any DEBUG and TRACE.
To keep things simple, try this... set the root logger to trace:-
log4j.rootLogger=TRACE, stdout
Then, comment out the following lines:-
#log4j.logger.petascope=INFO
#log4j.logger.petascope.wcps=DEBUG
#log4j.logger.petascope.wcst=DEBUG
#log4j.logger.petascope.wcs=DEBUG
#log4j.logger.petascope.wcs2=TRACE
Let me know if that works for you.
Try this:
log4j.appender.stdout.Threshold=TRACE
(as described in another StackOverflow question).