tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Rosenberg" <>
Subject Re: Appeal to Tomcat developers
Date Thu, 16 Oct 2008 13:17:18 GMT
On Thu, Oct 16, 2008 at 3:06 PM, David kerber <> wrote:
> Leon Rosenberg wrote:
>> On Thu, Oct 16, 2008 at 2:48 PM, David kerber <>
>> wrote:
>>> For my part, I generally agree with the OP.  Specifically, the show
>>> stopper
>>> for me is that the documentation isn't detailed enough at the level of
>>> the
>>> application and administrator level, and especially doesn't give enough
>>> examples of the different methods of logging.  I have looked at it
>>> extensively while reworking the app I inherited, and couldn't easily
>>> figure
>>> out how to configure logging to keep my app's log writes separate from
>>> Tomcat's without lots of experimentation (which didn't have time for), so
>>> I
>>> just left *everything* going to stdout.  Not the preferred method, I
>>> know,
>>> but how to configure it otherwise was not clear enough for me.
>>> Dave
>> I am sorry, but do you always log to system.out in your applications?
>> Maybe you should take a look at some of numerous logging projects,
>> starting with
>> log4j as the most prominent.
> Yes, system.out, and that is my point:  I have looked at the log4j docs
> extensively, and could not figure out how to use it without investing more
> time than I had available.  There either weren't enough practical examples,
> or not enough detailed instructions.
> Essentially I'm agreeing with the OP that either configuring it is too
> complex, or the docs don't make it clear how to do it simply.  I'm not sure
> which is really the problem, but I suspect it's the docs rather than the
> process itself.
> D

Errm, I'm sorry, but how is that related to tomcat?
Basically you have to add one line to your class to use log4j:

	private static Logger log = Logger.getLogger(CurrentClassName.class);

now anywhere in the class just do :"message");
   }catch(Exception e){
      log.error("methodname("+parameters+")", e);

You need to more things to configure it properly, one of them is
nearly done automatically, but to be sure just create a context
listener and add to contextinitialization:

and now an example for the log4j xml
	<appender name="ErrorAppender" class="org.apache.log4j.RollingFileAppender">
    	<param name="File" value="logs/error.log" />
    	<param name="Threshold" value="ERROR" />
    	<param name="MaxFileSize" value="100MB" />
    	<param name="MaxBackupIndex" value="5" />
    	<layout class="org.apache.log4j.PatternLayout">
      		<param name="ConversionPattern"
				value="%r %d{ISO8601} %-5p %c - %m%n"/>

 	<logger name="com.bla.your.package" additivity="true">
		<level value="ERROR"/>
		<appender-ref ref="ErrorAppender"/>

and so on...

read docs on more :-)


> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message