You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jim Patrick <ji...@yahoo.com> on 2012/11/09 23:49:02 UTC
Using FileAppender - Unable to log to a file
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
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
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Using-FileAppender-Unable-to-log-to-a-file-tp34694.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Using FileAppender - Unable to log to a file
Posted by Tushar Kapila <tg...@gmail.com>.
On my mobile so can't give you exact name. But you can search for the
windows property to tell log4j to print debug of its set up. This
miguel help.
Are you running on windows? I see your log file is /logs/.. That might
go to the drive where your server is running. Meaning if your server
is in c:\apps\jboss then your logs will go to c:\ try there. If your
on linux you might have folder permission issues.
That is assuming their is no error in the config. If you still have
not solved this can send you a sample.
On 11/10/12, Jim Patrick <ji...@yahoo.com> wrote:
> 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
>
> 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
>
>
>
> --
> View this message in context:
> http://apache-logging.6191.n7.nabble.com/Using-FileAppender-Unable-to-log-to-a-file-tp34694.html
> Sent from the Log4j - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
--
Sent from my mobile device
Regards
Tushar Kapila
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Using FileAppender - Unable to log to a file
Posted by Jim Patrick <ji...@yahoo.com>.
Hi
Could anyone add your thoughts?
Thanks,
-Jim
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Using-FileAppender-Unable-to-log-to-a-file-tp34694p34695.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org