= Log4j wiki migrated to a [http://wiki.apache.org/logging-log4j/Log4JProjectPages new home]. This page is no longer updated! =
I have a socket appender attached to my EJB which works great. the trouble is when i try and redeploy.. if i have a socket server connected to the log4j socket appender, it won't undeploy the ejb and in fact, it hangs the app server (weblogic 7). if i shut down the socket server (lumbermill for example) it will redeploy fine..
Does anyone have any thoughts?
MattFatt msweetnam@agentis.net
Hello all,
I'm having trouble seeing the Class reference and line number in the output. Here is the relevant config line.
log4j.appender.stdout.layout.ConversionPattern=%d %5p (%F:%L) - %m%n
Instead of seeing (class name:line number) I see (?:?)
2004-02-25 15:22:35,212 INFO (?:?) - Creating instance of the DataCache object.
I am running this from a J2EE app using WebLogic Server 8.1.
Thanks,
Cory
Hi,
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
log4j.additivity.org.apache.log4j.net.SimpleSocketServer=false
log4j.category.org.apache.log4j.net.SocketNode=DEBUG
log4j.appender.A1=org.apache.log4j.lf5.LF5Appender
log4j.appender.A1.MaxNumberOfRecords=200
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=error.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=[slf5s.start]%d{DATE}[slf5s.DATE]%n
{{{ %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
@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); }
- }}}
How can I enable a "live log" console on another machine from where the logging is taking place. is there some way to use a java applet or other such mechanism to display log messages live? wondering if there is some code for a console on another machine already.
also is there a way to view the logs in reverse order, so the most recent log is displayed first? this would be most useful for big files.
thanks, mark
Mark,
I think what you are looking for is provided by the Chainsaw tool <http://logging.apache.org/log4j/docs/chainsaw.html>. It works with the <code>org.apache.log4j.net.SocketAppender</code> class to provide a "live" view of log events.
Bree
Why do i get a duplicate output to console from my logger - i have a single simple appender, if i config it to info or debug level, then whenever i use a info or debug command i get the same message printed twice (almost):
static Logger logger = Logger.getLogger("agent");
...
Layout simpleLayout = new SimpleLayout();
logger.addAppender( new ConsoleAppender(simpleLayout));
logger.setLevel(Level.INFO);
logger.info("welcome to agentcontrol");Gives:
INFO - welcome to agentcontrol - welcome to agentcontrol
Anyone know what i'm doing wrong??? - i'm running in jbuilder, but a similar problem occurs when printing to the tomcat console.
Thanks, Oliver
- to answer my own question logger.setAdditivity(false); seems to do the trick.
Oliver,
This generally happens when you have two categories that are configured in such a way that one log event is "captured" by both categories. For example you may have your "root" category configured to capture messages of info an higher and a "com.youcompany" appender configured to capture messages of debug and higher. With this configuration you would see duplicate messages of type info and higher. You can verify this by creating two different appenders/layouts and configure your two categories to each use a different appender/layout. This is your issue if your "duplicate" messages start showing up in two different formats.
Bree
Is there any way (maybe an Ant("build.xml") target(?)) compiling a log4j-mini-jar? Like with commons-logging-api.jar (the mini version) and commons-logging.jar (the one with all stuff included). The reason is, that I want a "headless" version to be included in server application, which doesn't need Chainsaw, LF5 and other things. Christian