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 Ceki Gülcü <ce...@qos.ch> on 2002/12/10 15:54:26 UTC

Re: Error in renaming the file During DailyRollover option

Which server engine is this? What is your config file?

At 00:19 19.12.2002 +0530, Shailesh Vaidya wrote:

>Hi,
>
>I am trying to use DailyRollingFileAppender. When the  logger tries to
>rollover and rename the file we get a error message
>
>Can not rename the file exaple.log to example.log.mm-dd-yyyy". The reason is
>the file remains open. I am logging in a servlet
>
>the code is
>
>import java.io.*;
>import org.apache.log4j.*;
>import javax.servlet.http.HttpServlet;
>
>public class LoggingServlet extends HttpServlet {
>
>
>         public void doGet(
>             javax.servlet.http.HttpServletRequest request,
>                 javax.servlet.http.HttpServletResponse response)
>                 throws javax.servlet.ServletException, java.io.IOException {
>           Logger log = Logger.getLogger("log1");
>           log.debug("Start of main()");
>         log.info("Just testing a log message with priority set to INFO");
>         log.warn("Just testing a log message with priority set to WARN");
>         log.error("Just testing12 a log message with priority set to
>ERROR");
>         log.fatal("Just testing a log message with priority set to FATAL");
>
>    }
>}
>
>Actually the error occurs because the file is locked by the servlet engine
>even when the doGet method finishes. The lock gets released only when I stop
>the servlet engine.
>
>How could we rectify this error so that rollover happens properly.
>
>Thanks in advance for any help.
>
>
>Shailesh
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error in renaming the file During DailyRollover option

Posted by Shailesh Vaidya <Sh...@yojna.com>.
Hi,

I run the same servlet many times at diffrent times. Actually the file
remains open even when the doget method is finished. So when the log4j
appender tries to rename the file at rollover time when the same servlet is
executed the next day it gets an error.

Is  the file be opened or closed at each debug or info statement ?. Can
somebody throw light on when exactly the file is opened and closed for
fileappenders. That is the key to this problem. One way is to go through the
source code and find out but I was trying to save that time.

Thanks in advance for any help.

Regards

Shailesh

-----Original Message-----
From: Ceki Gulcu [mailto:ceki@qos.ch]
Sent: Tuesday, December 10, 2002 8:51 PM
To: Log4J Users List
Subject: RE: Error in renaming the file During DailyRollover option



Is the previous run of your servlet closed and unloaded when you run the
new version? What happens if you change the DatePattern to
.yyyy-MM-dd-HH-mm (minutely rollover)? Do rollovers occur?

At 20:43 10.12.2002 +0530, Shailesh Vaidya wrote:
>I am using WebSphere Application Developer Test Engine. The Config file
>details are as follows. I am using the default config file log4j.properties
>and it is kept in web-inf\classes directly. The messages are properly
>logged. Just that file remains open even when the doGet method is over.
When
>I try to run the servlet the next day ( by changing the system date and
>time) I get the message "log4j:ERROR Failed to rename [d:\ajit\example] to
>[d:\ajit\example.2002-12-18]."
>
>********************************
>log4j.rootCategory=WARN,R
>log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
>log4j.appender.R.File=d:\\ajit\\example
>log4j.appender.R.layout=org.apache.log4j.PatternLayout
>log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
>log4j.appender.R.DatePattern='.'yyyy-MM-dd
>***********************
>
>
>Shailesh
>
>-----Original Message-----
>From: Ceki Gulcu [mailto:ceki@qos.ch]
>Sent: Tuesday, December 10, 2002 8:24 PM
>To: Log4J Users List
>Subject: Re: Error in renaming the file During DailyRollover option
>
>
>
>Which server engine is this? What is your config file?
>
>At 00:19 19.12.2002 +0530, Shailesh Vaidya wrote:
>
> >Hi,
> >
> >I am trying to use DailyRollingFileAppender. When the  logger tries to
> >rollover and rename the file we get a error message
> >
> >Can not rename the file exaple.log to example.log.mm-dd-yyyy". The reason
>is
> >the file remains open. I am logging in a servlet
> >
> >the code is
> >
> >import java.io.*;
> >import org.apache.log4j.*;
> >import javax.servlet.http.HttpServlet;
> >
> >public class LoggingServlet extends HttpServlet {
> >
> >
> >         public void doGet(
> >             javax.servlet.http.HttpServletRequest request,
> >                 javax.servlet.http.HttpServletResponse response)
> >                 throws javax.servlet.ServletException,
java.io.IOException
>{
> >           Logger log = Logger.getLogger("log1");
> >           log.debug("Start of main()");
> >         log.info("Just testing a log message with priority set to
INFO");
> >         log.warn("Just testing a log message with priority set to
WARN");
> >         log.error("Just testing12 a log message with priority set to
> >ERROR");
> >         log.fatal("Just testing a log message with priority set to
>FATAL");
> >
> >    }
> >}
> >
> >Actually the error occurs because the file is locked by the servlet
engine
> >even when the doGet method finishes. The lock gets released only when I
>stop
> >the servlet engine.
> >
> >How could we rectify this error so that rollover happens properly.
> >
> >Thanks in advance for any help.
> >
> >
> >Shailesh
> >
> >
> >--
> >To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
> >For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>--
>Ceki
>
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
>For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
>For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error in renaming the file During DailyRollover option

Posted by Shailesh Vaidya <Sh...@yojna.com>.
Hi,

When I put the log4j.jar in the classpath of webSphere application developer
server test engine, the original problem of renaming file error does not
occur. But I have observed a strange behavior. my observations are as
follows.

1. When I run the servlet code in debug mode the rollover happens smoothly
everytime without any problem when I change the system date.

In normal run the behaviour changes

2. When I run the servlet once in  a day. Change the system date and run the
servlet again the rollover occurs and the original file is renamed.

3. If I run the servlet twice in a day. The log messages go to the same file
even if I change the system date and run the servlet again.

Can somebody throw light on this strange behaviour.  I am using
immidateflush as true. ( the default value)

regards

Shailesh


-----Original Message-----
From: Ceki Gulcu [mailto:ceki@qos.ch]
Sent: Tuesday, December 10, 2002 8:51 PM
To: Log4J Users List
Subject: RE: Error in renaming the file During DailyRollover option



Is the previous run of your servlet closed and unloaded when you run the
new version? What happens if you change the DatePattern to
.yyyy-MM-dd-HH-mm (minutely rollover)? Do rollovers occur?

At 20:43 10.12.2002 +0530, Shailesh Vaidya wrote:
>I am using WebSphere Application Developer Test Engine. The Config file
>details are as follows. I am using the default config file log4j.properties
>and it is kept in web-inf\classes directly. The messages are properly
>logged. Just that file remains open even when the doGet method is over.
When
>I try to run the servlet the next day ( by changing the system date and
>time) I get the message "log4j:ERROR Failed to rename [d:\ajit\example] to
>[d:\ajit\example.2002-12-18]."
>
>********************************
>log4j.rootCategory=WARN,R
>log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
>log4j.appender.R.File=d:\\ajit\\example
>log4j.appender.R.layout=org.apache.log4j.PatternLayout
>log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
>log4j.appender.R.DatePattern='.'yyyy-MM-dd
>***********************
>
>
>Shailesh
>
>-----Original Message-----
>From: Ceki Gulcu [mailto:ceki@qos.ch]
>Sent: Tuesday, December 10, 2002 8:24 PM
>To: Log4J Users List
>Subject: Re: Error in renaming the file During DailyRollover option
>
>
>
>Which server engine is this? What is your config file?
>
>At 00:19 19.12.2002 +0530, Shailesh Vaidya wrote:
>
> >Hi,
> >
> >I am trying to use DailyRollingFileAppender. When the  logger tries to
> >rollover and rename the file we get a error message
> >
> >Can not rename the file exaple.log to example.log.mm-dd-yyyy". The reason
>is
> >the file remains open. I am logging in a servlet
> >
> >the code is
> >
> >import java.io.*;
> >import org.apache.log4j.*;
> >import javax.servlet.http.HttpServlet;
> >
> >public class LoggingServlet extends HttpServlet {
> >
> >
> >         public void doGet(
> >             javax.servlet.http.HttpServletRequest request,
> >                 javax.servlet.http.HttpServletResponse response)
> >                 throws javax.servlet.ServletException,
java.io.IOException
>{
> >           Logger log = Logger.getLogger("log1");
> >           log.debug("Start of main()");
> >         log.info("Just testing a log message with priority set to
INFO");
> >         log.warn("Just testing a log message with priority set to
WARN");
> >         log.error("Just testing12 a log message with priority set to
> >ERROR");
> >         log.fatal("Just testing a log message with priority set to
>FATAL");
> >
> >    }
> >}
> >
> >Actually the error occurs because the file is locked by the servlet
engine
> >even when the doGet method finishes. The lock gets released only when I
>stop
> >the servlet engine.
> >
> >How could we rectify this error so that rollover happens properly.
> >
> >Thanks in advance for any help.
> >
> >
> >Shailesh
> >
> >
> >--
> >To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
> >For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>--
>Ceki
>
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
>For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
>For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error in renaming the file During DailyRollover option

Posted by Ceki Gülcü <ce...@qos.ch>.
Is the previous run of your servlet closed and unloaded when you run the 
new version? What happens if you change the DatePattern to 
.yyyy-MM-dd-HH-mm (minutely rollover)? Do rollovers occur?

At 20:43 10.12.2002 +0530, Shailesh Vaidya wrote:
>I am using WebSphere Application Developer Test Engine. The Config file
>details are as follows. I am using the default config file log4j.properties
>and it is kept in web-inf\classes directly. The messages are properly
>logged. Just that file remains open even when the doGet method is over. When
>I try to run the servlet the next day ( by changing the system date and
>time) I get the message "log4j:ERROR Failed to rename [d:\ajit\example] to
>[d:\ajit\example.2002-12-18]."
>
>********************************
>log4j.rootCategory=WARN,R
>log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
>log4j.appender.R.File=d:\\ajit\\example
>log4j.appender.R.layout=org.apache.log4j.PatternLayout
>log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
>log4j.appender.R.DatePattern='.'yyyy-MM-dd
>***********************
>
>
>Shailesh
>
>-----Original Message-----
>From: Ceki Gulcu [mailto:ceki@qos.ch]
>Sent: Tuesday, December 10, 2002 8:24 PM
>To: Log4J Users List
>Subject: Re: Error in renaming the file During DailyRollover option
>
>
>
>Which server engine is this? What is your config file?
>
>At 00:19 19.12.2002 +0530, Shailesh Vaidya wrote:
>
> >Hi,
> >
> >I am trying to use DailyRollingFileAppender. When the  logger tries to
> >rollover and rename the file we get a error message
> >
> >Can not rename the file exaple.log to example.log.mm-dd-yyyy". The reason
>is
> >the file remains open. I am logging in a servlet
> >
> >the code is
> >
> >import java.io.*;
> >import org.apache.log4j.*;
> >import javax.servlet.http.HttpServlet;
> >
> >public class LoggingServlet extends HttpServlet {
> >
> >
> >         public void doGet(
> >             javax.servlet.http.HttpServletRequest request,
> >                 javax.servlet.http.HttpServletResponse response)
> >                 throws javax.servlet.ServletException, java.io.IOException
>{
> >           Logger log = Logger.getLogger("log1");
> >           log.debug("Start of main()");
> >         log.info("Just testing a log message with priority set to INFO");
> >         log.warn("Just testing a log message with priority set to WARN");
> >         log.error("Just testing12 a log message with priority set to
> >ERROR");
> >         log.fatal("Just testing a log message with priority set to
>FATAL");
> >
> >    }
> >}
> >
> >Actually the error occurs because the file is locked by the servlet engine
> >even when the doGet method finishes. The lock gets released only when I
>stop
> >the servlet engine.
> >
> >How could we rectify this error so that rollover happens properly.
> >
> >Thanks in advance for any help.
> >
> >
> >Shailesh
> >
> >
> >--
> >To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
> >For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>--
>Ceki
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>

--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Error in renaming the file During DailyRollover option

Posted by Shailesh Vaidya <Sh...@yojna.com>.
I am using WebSphere Application Developer Test Engine. The Config file
details are as follows. I am using the default config file log4j.properties
and it is kept in web-inf\classes directly. The messages are properly
logged. Just that file remains open even when the doGet method is over. When
I try to run the servlet the next day ( by changing the system date and
time) I get the message "log4j:ERROR Failed to rename [d:\ajit\example] to
[d:\ajit\example.2002-12-18]."

********************************
log4j.rootCategory=WARN,R
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=d:\\ajit\\example
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R.DatePattern='.'yyyy-MM-dd
***********************


Shailesh

-----Original Message-----
From: Ceki Gulcu [mailto:ceki@qos.ch]
Sent: Tuesday, December 10, 2002 8:24 PM
To: Log4J Users List
Subject: Re: Error in renaming the file During DailyRollover option



Which server engine is this? What is your config file?

At 00:19 19.12.2002 +0530, Shailesh Vaidya wrote:

>Hi,
>
>I am trying to use DailyRollingFileAppender. When the  logger tries to
>rollover and rename the file we get a error message
>
>Can not rename the file exaple.log to example.log.mm-dd-yyyy". The reason
is
>the file remains open. I am logging in a servlet
>
>the code is
>
>import java.io.*;
>import org.apache.log4j.*;
>import javax.servlet.http.HttpServlet;
>
>public class LoggingServlet extends HttpServlet {
>
>
>         public void doGet(
>             javax.servlet.http.HttpServletRequest request,
>                 javax.servlet.http.HttpServletResponse response)
>                 throws javax.servlet.ServletException, java.io.IOException
{
>           Logger log = Logger.getLogger("log1");
>           log.debug("Start of main()");
>         log.info("Just testing a log message with priority set to INFO");
>         log.warn("Just testing a log message with priority set to WARN");
>         log.error("Just testing12 a log message with priority set to
>ERROR");
>         log.fatal("Just testing a log message with priority set to
FATAL");
>
>    }
>}
>
>Actually the error occurs because the file is locked by the servlet engine
>even when the doGet method finishes. The lock gets released only when I
stop
>the servlet engine.
>
>How could we rectify this error so that rollover happens properly.
>
>Thanks in advance for any help.
>
>
>Shailesh
>
>
>--
>To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
>For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
Ceki



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>