• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using FileAppender - Unable to log to a file

 
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am new to using log4j. I am just trying out a sample Java web application using tomcat6.0.18, log4j(log4j1.2.11.jar), Struts, and Eclipse Juno IDE on Windows

My Issue - I can see the DEBUG and INFO logs in eclipse console window but somehow they are not logged to a file. Not sure if I have missed something.
Could someone please help me?

Below is the log4j configuration in my sample application for reference:


1) log4j.properties:
I have this file under src folder in my application in eclipse IDE


log4j.rootLogger=DEBUG, myDebug, myConsole

# Configure the myConsoleappender
log4j.appender.myConsole=org.apache.log4j.ConsoleAppender
log4j.appender.myConsole.layout=org.apache.log4j.PatternLayout
log4j.appender.myConsole.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n

# Configure the myDebug appender
log4j.appender.myDebug=org.apache.log4j.RollingFileAppender
log4j.appender.myDebug.File=/logs/mylog.log
log4j.appender.myDebug.MaxFileSize=100000KB
log4j.appender.myDebug.MaxBackupIndex=1
log4j.appender.myDebug.Threshold=DEBUG
log4j.appender.myDebug.layout=org.apache.log4j.PatternLayout
log4j.appender.myDebug.layout.ConversionPattern=%d{yyyy-MMM-dd HH:mm:ss,SSS} - %p %c - %m%n


2) web.xml:

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>com.vprapplication.struts.VPRActionServlet</servlet-class>
<init-param>
<param-name>log4j-properties-location</param-name>
<param-value>WEB-INF/log4j.properties</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


Please let me know if any other details are needed.

Thanks in advance,

-Jim Patrick
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you are looking in the wrong place for those log files? I don't see anything wrong with what you posted, and it says to write the logs into the /logs folder. So do you have such a folder? Does your server have permission to write in it and create files in it?
 
reply
    Bookmark Topic Watch Topic
  • New Topic