Dear all:

I try to put a file 'log4j.properties' to the roof of the source fold. And any 
class which use Log4j to output can use the properties.
I don't use Apache Struts, but I think copying the log4j.properties to WEB-INF 
should be OK.

The follow is the content of 'log4j.properties' 
--------------------------
# All logging output sent to standard out and a file
# WARN is default logging level
log4j.rootCategory=WARN, STDOUT

# Application logging level is DEBUG
log4j.logger.com.discursive=ERROR, FILE

# Configure the Standard Out Appender
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%5p (%F:%L) %m%n

# Configure a rolling file appender
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=output.log
log4j.appender.FILE.MaxFileSize=2000KB
log4j.appender.FILE.MaxBackupIndex=5
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=%d %-5p %c - %m%n
----------------------------










----------------
Kenneth Huang
2006-06-14



Darren  Hall  wrote:
>  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?

Did  you  create  the  log  directory?  I  don't  think  that  log4j  creates  
directories  by  itself,  but  it  might  differ  between  the  various  
appenders.

--  
Dennis  Lundberg


>  
>  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:[EMAIL PROTECTED]  
>  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:[EMAIL PROTECTED]  
> >  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.
> >
> >
>  
>  

---------------------------------------------------------------------
To  unsubscribe,  e-mail:  [EMAIL PROTECTED]
For  additional  commands,  e-mail:  [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to