

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
20 messages in org.apache.logging.log4j-userRE: Separate log file per servlet| From | Sent On | Attachments |
|---|---|---|
| Horry, Adam J | Jun 11, 2004 10:05 am | |
| James Stauffer | Jun 11, 2004 10:20 am | |
| Shapira, Yoav | Jun 11, 2004 10:23 am | |
| Horry, Adam J | Jun 11, 2004 10:29 am | |
| Horry, Adam J | Jun 11, 2004 10:33 am | |
| Lutz Michael | Jun 11, 2004 10:33 am | |
| Shapira, Yoav | Jun 11, 2004 10:58 am | |
| James Stauffer | Jun 11, 2004 11:02 am | |
| Horry, Adam J | Jun 11, 2004 11:48 am | |
| James Stauffer | Jun 11, 2004 11:50 am | |
| Ceki Gülcü | Jun 11, 2004 12:08 pm | |
| Scott Deboy | Jun 11, 2004 12:13 pm | |
| Horry, Adam J | Jun 11, 2004 1:29 pm | |
| Horry, Adam J | Jun 11, 2004 1:37 pm | |
| Horry, Adam J | Jun 11, 2004 1:40 pm | |
| James Stauffer | Jun 11, 2004 1:42 pm | |
| Ceki Gülcü | Jun 11, 2004 1:49 pm | |
| Scott Deboy | Jun 11, 2004 1:50 pm | |
| Horry, Adam J | Jun 11, 2004 2:10 pm | |
| Ceki Gülcü | Jun 11, 2004 2:16 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | RE: Separate log file per servlet | Actions... |
|---|---|---|
| From: | Scott Deboy (sde...@comotivsystems.com) | |
| Date: | Jun 11, 2004 1:50:29 pm | |
| List: | org.apache.logging.log4j-user | |
Chainsaw can read log files created using XmlLayout, but it can also read log files created using PatternLayout.
The JavaDoc of LogFilePatternReceiver provides an example. Using a log file with this patternLayout: %d %-5p [%t] %C{2} (%F:%L) - %m%n
Can be processed by Chainsaw using a LogFilePatternReceiver with this logFormat: TIMESTAMP LEVEL [THREAD] CLASS (FILE:LINE) - MESSAGE
You'll also have to specify the timestamp format, the file name being processed, and whether or not you want to 'tail' the file.
Scott
-----Original Message----- From: Horry, Adam J [mailto:adam...@lmco.com] Sent: Friday, June 11, 2004 1:41 PM To: Log4J Users List Subject: RE: Separate log file per servlet
Thanks, I brough up chainsaw and am looking at how to use it.
One quick question from the docs. Does the log file have to be in xml?
Adam
-----Original Message----- From: Scott Deboy [mailto:sde...@comotivsystems.com] Sent: Friday, June 11, 2004 3:14 PM To: Log4J Users List Subject: RE: Separate log file per servlet
I think Chainsaw might be able to help here.
I'd suggest setting an MDC on the servlet's entry point (say 'servlet' key with the value being the servlet class), and then using patternlayout, set up all of the fields you need to log (including this newly-added MDC entry). All of the servlets can log to the same file.
Then, using Chainsaw V2 (http://logging.apache.org/log4j/docs/chainsaw.html), configure a LogFilePatternReceiver, specifying the pattern in your file (including the MDC entry). See the javadoc for how to specify the pattern: http://cvs.apache.org/viewcvs.cgi/jakarta-log4j/src/java/org/apache/log4 j/varia/LogFilePatternReceiver.java?rev=1.12&view=markup
Enable the 'tailing' flag to 'tail' the file (as events are added to the file, they'll show up in Chainsaw).
The events will load in Chainsaw, and you'll be able to sort/filter/etc.
If you'd like to filter events before they're added to the UI, specify a 'filterExpression' on the LogFilePatternReceiver config (for example, specifying PROP.servlet = 'my.servlet.class' will pass only events with that MDC value on to Chainsaw.
Hope this helps, Scott
-----Original Message----- From: Horry, Adam J [mailto:adam...@lmco.com] Sent: Friday, June 11, 2004 11:49 AM To: Log4J Users List Subject: RE: Separate log file per servlet
Unfortunately, I have a Web Architect who wants it this way and it is my job to make it happen.
My original idea was to output to a log in XML and then create an XML tool to filter/sort/etc.
I had thought of the stack trace method but that seemed like a performance hog. I thought about messing this the events but that seemed even uglier.
I will look at the AOP Aspects. Not familiar with it but I am opening to any suggestion at this point.
Thanks, Adam
-----Original Message----- From: James Stauffer [mailto:jsta...@spscommerce.com] Sent: Friday, June 11, 2004 2:02 PM To: 'Log4J Users List' Subject: RE: Separate log file per servlet
You could set an MDC with the servlet name and then filter the logs.
James Stauffer
-----Original Message----- From: Shapira, Yoav [mailto:Yoav...@mpi.com] Sent: Friday, June 11, 2004 12:59 PM To: Log4J Users List Subject: RE: Separate log file per servlet
Hi,
1) What is the reason for setting additivity to false in this scenario 2) does additivity need to be set to false for each appender in this scenario, or only the first?
In my example, I set additivity to false for all the appenders, because I didn't know what was in the rest of his configuration file. It's better to over-isolate than get multiple copies of logging statements IMHO, but it's certainly not a requirement, and certainly more details need to be known in order to establish if that's a good approach for this scenario.
As for configuring log4j: do it once, in a ServletContextListener's contextInitialized method, not from a servlet.
As for the shared class using whatever appender its calling class is using: ack, that's a bit of a pain. Logging Domains would help here, but that's log4j 1.3 ;) You can also do this fairly nicely with some Aspects (as in AOP Aspects). You could pass the name of the calling class, the calling class itself, or the Logger object itself, to all methods in the shared class. That's simple and would work, though it's a bit ugly. You could figure out the calling class name using stack trace tricks, but that's costly from a performance perspective. I don't know what I'd pick in this scenario, but then again I wouldn't be in this scenario to start with because I really dislike the "every component [or class, or whatever] goes into its own log destination" approach -- I prefer sending everything to one destination and then filtering/viewing using a good tool like Chainsaw or emacs ;)
Yoav Shapira
This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you.
--------------------------------------------------------------------- To unsubscribe, e-mail: log4...@logging.apache.org For additional commands, e-mail: log4...@logging.apache.org
--------------------------------------------------------------------- To unsubscribe, e-mail: log4...@logging.apache.org For additional commands, e-mail: log4...@logging.apache.org
--------------------------------------------------------------------- To unsubscribe, e-mail: log4...@logging.apache.org For additional commands, e-mail: log4...@logging.apache.org







