Log4j Frequently Asked Questions

If you do not see your question below, you may want to first ask it on the log4j-user email list. There will be a much quicker response time. Then, after you get an answer, come back to this page and add it to the list for future reference.

Some frequently asked questions (FAQs):

How do I configure log4j component X in XML?

Please see Log4jXmlFormat?

How do I configure JDBCAppender?

Please see JDBCAppenderConfiguration

What are the NDC and MDC classes used for in log4j and which one should I use?

Please see NDCvsMDC

Why would I use Log4J when Sun has a logging API?

Please see Log4jvsJDKLogging.

How can I get log messages of different level values into different log files?

Please see [ LogByLevel ]

How can I add a new Level?

See example in [ TraceLevel ].

How do I start the LogFactor5 tool?

Please see LogFactor5FAQ

Where are the example log4j.xml files located?

Please see XMLConfigurationExamples.

How do I configure log4j so that programs in multiple JVMs can log to the same file and rollover daily (using org.apache.log4j.DailyRollingFileAppender)? Does org.apache.log4j.net.SocketAppender need to be used?

 

How do I upgrade from log4j 1.0.x or 1.1.x to log4j 1.2.x?

Please see Log4jUpgradePath

How do I determine if a particuliar log level is set (to avoid multiple evaluations of logging statements)?

The Logger class supports the methods

 isDebugEnabled(), isInfoEnabled(), and isWarnEnabled(). 

Why do you have both logfactor5 and chainsaw? Which one is better maintained/more current?

Please see Logfactor5vsChainsaw.

Are there step-by-step instructions for using Chainsaw to view log events from a SocketHubAppender?

Please see ChainsawAndSocketHubWalkthrough.

How do I log in a container environment without colliding with the logging configuration of other applications using Log4j?

Please see [ AppContainerLogging ]

What about the Jakarta Commons logging API?

 

Can I send mails to multiple recipients using SMTP Appender of log4j. If yes how should I build the XML file for this so that I can pass it to DOMConfigurator?

 

How much longer will my program work if I use log4j?

 

Where are the example log4j.properties files located?

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="60bdd296-9171-43c4-8355-a43558a95354"><ac:plain-text-body><![CDATA[

Is there an OS web service implementation of Log4J?

[To whom it may concern: can you please elaborate?]

]]></ac:plain-text-body></ac:structured-macro>

How is log cleanup handled when using DailyRollingFileAppender?

 

Is it possible to make LogFactor5 open a particular URL/log on start up (for viewing)?

 

Is log4j thread-safe? E.g. can I use the same Logger in different threads for log.info()?

The answer is yes.

Should Logger variables be declared static?

See [ Log4JStatic ]

When log4j is installed on tomcat on windows 2000, the server restarts whereas if it is on windows 98 it works well. Can anyone help me?

 

My project is currently using System.out.println() statements to print debug statements. Is there any automated process to replace these statements with debug statements?

 

Is it possible to use log4j to log a) html form submission, b) hyperlink clicks, c) points in a

 JavaScript 

function as it's being executed?

 

What's the rationale behind LogFactor5 not System.exit()ing when you click the close button? What purpose is there for that JVM left running? Can you get the window back without starting a new session?

 

What's the fix for a socket write error when trying to write to Chainsaw?

See [ ChainsawLocationInfo ]

How can I write different level of logs to different files?

See [ LogToAppenderByLevel ]

Is it possible to pass a System Property as part of a file name for a file appender? Rather than setting the file name programatically?

See [ SystemPropertiesInConfiguration ]

How can I get notified of errors during configuration and then handle them? For example, I want to log to a file but the directory does not exist yet. I want to catch that configuration error, create the directory and restart configuration.

 

How can I make the log4j output in Eclipse act as links into my source code? If I use the "%l" in my PatternLayout I get a hyperlink, but I get an Eclipse parse error when I click on it.

 

How I can log message with single quote

 

How I get automatic configuration to work?

See Log4jConfigurationHelp

What do I do when I get "log4j:WARN No appenders could be found for logger"

See Log4jConfigurationHelp

Chainsaw frequently asked questions (FAQs):

  • No labels