I have a general question about Chainsaw. How much can we customize its functionality and user interface? Can I get its source code and adapt it based on our needs? Also, can you give me any instructions on building the application?

Thanks in advance,



A question about Chainsaw V2. In the release_20060302 tagged version of it, there was shown the following plugin config in the example receiver configuration:

When I a config file to define a receiver to Chainsaw using that pattern, Chainsaw threw a "class not found" java exception on "org.apache.log4j.xml.LogFileXMLReceiver". This occurred both running from a downloaded copy of Chainsaw and from the Webstart access. Do I need to set up access to some other jar, or is this V2 version of Chainsaw that half baked that it's yet missing class implementations that are yet to be developed?

Thanks for whatever help you can provide.


I have a question regarding using the SocketAppender and a socket server (be it SimpleSocketServer, or some other implementation). In my environment, I have many different (smallish) Java applications, on separate machines, that all use Log4J, and I reconfigured them all to use a SocketAppender. That part's actually pretty easy. The difficult part that I'm running into is that when I'm processing the incoming log event object, I would like to add information about the system from which the log message was generated (such as the hostname, IP address, etc). Ideally, I'd like to extend the PatternFormat class to allow the formatting of these additional fields (instead of simply adding the hostname and IP when the message is received). I've messed around with extending the Logger class, the LoggingEvent class, and several others. My current (and highly undesirable) solution is to actually modify the log4j source so that when a Logger is retrieved, using the built-in java.net classes, I can automatically grab the information from the host on which the message is being generated, and populate it into a LoggingEvent.

Am I completely missing a standardized way of doing this? Any help is greatly appreciated!

Thanks! Robert


I am using log4j to create multiple log files (like error log, audit.log). I am using a SocketAppender on the client side. I am running a SimpleSocketServer on the remote server. I want the output to be logged to various files in different locations on the server side. Previously, I used a FileAppender and programmatically was able to create files in different locations easily on the client machine.

Example: /logs/audit.log /Data/client1.log /Data/client2.log /history/history.log    How do I do the same thing using SocketAppender and create these files remotely on a server in different locations? Using a config/properties file on the server side; I can create only one output file.    Attached is the sample properties file I am using on the server side.

log4j.rootCategory=DEBUG, A1
log4j.category.org.apache.log4j.net.SimpleSocketServer=, A1
{{{  %p[slf5s.PRIORITY]%n%x[slf5s.NDC]%n%t[slf5s.THREAD]%n

  %c[slf5s.CATEGORY]%n%l[slf5s.LOCATION]%n%m[slf5s.MESSAGE]%n%n  log4j.appender.R.MaxFileSize=200KB log4j.appender.R.MaxBackupIndex=1

Has anyone faced the same situation?    Thanks Sudhakar

What layout must I use to get the stack-traces of exceptions (and nestes Exceptions if possible)? I cannot find anything about it in e.g. PatternLayout.


@Marcus: The methods to log information (debug(), info() etc.) accept a second parameter of the type java.lang.Throwable. When you pass your exception, the stack trace will be printed as part of your message.

Logger LOG = Logger.getLogger(this.getClass());
try {
{{{   throw new Exception();

} catch (Exception e) {    LOG.debug("Exception caught", e);  }

Hi, we are running several "user" objects within the same JVM. These classes represent a user in our system, in turn each User is made up of a collection of other classes. These other classes are all below user.* in the package hierarchy. We require logging for each user and the classes they are composed of, but for security reasons do not want the output to be all in the same file. i.e. we want a seperate logfile for each user. Our currently logging implementation interleaves all user logs into the same file. How can we use Log4j to have a seperate log file for each user and their component classes? It might be worth mentioning that each user does not necessarily operate in a different thread.

When I start my application, there are a few things that I'd like to drop into the log that would probably be considered INFO entries, but I don't want to turn on INFO logging for the entire app. For example, I'd like to drop in an entry that the application was started (so that restarts are clear in the log), environmental information, and so on cash advance. Is there a way to "force" an INFO entry to the log even though INFO logging is not on? Or maybe there's some other way to skin the cat?

This is someone else, but I have a very similar question to the one above. I am new to log4j, but am familar with a logging package that used numbers instead of names for logging levels. My question is this: using log4j, it seems that if I want a message to *always* appear in the log, I must log it at the level "fatal", even thought it may not actually be related to a fatal event at all (like the example above -- maybe I want to say "app started", etc.) With a numbered hierarchy, this is easy: log level 1 simply says "always appear in the log" -- using a level of 1 does not make a statement about whether a message is info or a warning or an error. The log4j named hierarchy inextricably binds the *kind* of event to the *frequency* with which it appears in the log, and this feels limiting after using a numbered hierarchy. Is there a way to get around this in log4j, and make sure something that is "information" (but important) *always* be written to the log?

QuestionAnswer (last edited 2012-06-19 06:47:38 by wau)