commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Hall" <dh...@utrs.com>
Subject RE: turning on debugging with commons logging
Date Tue, 13 Jun 2006 21:17:13 GMT
Excellent!

My application deploys with no exceptions - however (and now I'm venturing
into the Log4j side of things) I don't appear to be producing any log output
at all.

Dennis, if I could bother you one more time - I'm not sure how much of a
Log4j expert you are, but here is the log4j.xml file I've created (modified
from one I found online). When I deploy my war file and the servlet
initializes, it should produce logging output. In my log4j.xml file, I've
specified log file to be 'DailyFileAppender' types located in the 'log'
directory. However, after deploying my webapp, I can't find my log files
anywhere on my machine. Where did I go wrong?

Thanks for your help!

Darren

(log4j.xml)

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

  <appender name="event_file" class="org.apache.log4j.DailyFileAppender">
    <param name="Threshold" value="DEBUG"/>
    <param name="File" value="log/uwaf-event.log"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
    </layout>
  </appender>

  <appender name="error_file" class="org.apache.log4j.DailyFileAppender">
    <param name="Threshold" value="INFO"/>
    <param name="File" value="log/uwaf-error.log"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
    </layout>
  </appender>

  <appender name="console" class="org.apache.log4j.ConsoleAppender"> 
    <param name="Target" value="System.out"/> 
    <param name="Threshold" value="INFO"/>
    <layout class="org.apache.log4j.PatternLayout"> 
      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}]
%m%n"/>
    </layout> 
  </appender> 

  <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
    <appender-ref ref="event_file"/>
    <appender-ref ref="error_file"/>
  </appender>

  <!-- Setup the Root category -->
  <root>
    <appender-ref ref="ASYNC"/>
  </root>

</log4j:configuration>



-----Original Message-----
From: Dennis Lundberg [mailto:dennisl@apache.org] 
Sent: Tuesday, June 13, 2006 5:04 PM
To: Jakarta Commons Users List
Subject: Re: turning on debugging with commons logging

Darren Hall wrote:
> Thanks Dennis,
> 
> I'm using Struts "out of the box" so I have no logging package in place.
> I have no commons-logging.properties file and nothing referring to Log4J
or
> anything of the sort.
> 
> It seems to me that commons-logging is using the Tomcat default logging
> (thus it outputs to 'catalina.log').
> 
> I've gone ahead and downloaded Log4J and included the Log4J.jar file in my
> WEB-INF/lib directory when deploying my webapp. I've also created a
> commons-logging.properties file (below) that I found as an example online.
> 
> #########################
> 
> #
> # $Id: commons-logging.properties,v 1.0 2006/06/31 14:35:33Z dhall $
> # 
> 
> # 
> # This file controls which logging package the Jakarta Commons Logging
> package
> # uses. This can be changed to point to any supported logging package. See
> # http://jakarta.apache.org/commons/logging for a list of supported
logging
> # packages.
> # 
>
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.Log4jF
> actory
> 
> #########################
> 
> However, when I try to deploy my war file in Tomcat I now get a
> ClassDefNotFound org.apache.commons.logging.impl.Log4jFactory error.
> 
> On the commons-logging website, I see that Log4jFactory is deprecated and
> not included in commons-logging 1.1 and beyond.

You should use this line instead:
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

> How do I tell commons-logging to use Log4j (or do I not tell it since it
> looks for it by default)?

It's better to specify the logging implementation, if you want to be in 
control. Otherwise the logging implementation chosen by commons-logging 
might differ, for example on different servers like development and 
production.

> 
> Thanks,
> 
> Darren
> 
> 
> 
> -----Original Message-----
> From: Dennis Lundberg [mailto:dennisl@apache.org] 
> Sent: Tuesday, June 13, 2006 2:41 PM
> To: Jakarta Commons Users List
> Subject: Re: turning on debugging with commons logging
> 
> Darren Hall wrote:
>> Greeting all,
>>
>>  
>>
>> I'm having a hard time turning on debugging in Apache struts (which is
> using
>> commons logging).
>>
>> I know this should be easy to do, however I'm having a hard time finding
> the
>> information on the web.
>>
>> Can anyone here tell me how to configure commons logging so that it will
>> display DEBUG level statements, please (currently it displays on INFO
> level
>> and above)?
> 
> This all depends on what underlying logging implementation that your app 
> or Struts is using. I haven't used Struts myself, so cannot comment on 
> how to configure Struts.
> 
> The general user guide for commons-logging is here:
> http://jakarta.apache.org/commons/logging/commons-logging-1.1/guide.html
> 
> If your app is using SimpleLog then this is the good place to look:
>
http://jakarta.apache.org/commons/logging/apidocs/org/apache/commons/logging
> /impl/SimpleLog.html
> 
> If your app is using JDK logging (if you are running on Java 1.4+) you 
> should consult the documentation for the JDK.
> 
> 


-- 
Dennis Lundberg

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message