Hi Ceki,
my application runs under tomcat-3.2.2 thus it is a single application
but of course with several threads but one JVM. (My platform is
Red-Hat-6.0 and the latets IBM-JRE-1.1.8)
Where the strange log appears is a very simple code:
...
final static private Category log =
Category.getInstance("cb.show.gif");
...
public void doGet(...)
{
....
log.info("show giffile " + fullfilename);
...
}
I have the impression that log4j seeks back in the file and writes to a
strange location. All the older logs entries are already in the log file
before the strange log happens (I'm absolutely sure) log4j just writes
to a wrong location.
The only tricky thing what I do that I use LoggingOutputStream from
[EMAIL PROTECTED] and additionally I call the following method at
the beginning of my application:
private static void checkLog(ServletConfig config) // this method is
called when tomcat has been just started
throws ServletException
{
if (log != null)
{
return;
}
ServletContext context = config.getServletContext();
try
{
URL url = context.getResource("/log/log.cfg");
PropertyConfigurator.configure(url);
log = Category.getInstance("cb");
Utils.setErrOut(log);
log.info("Startup: " + new Date());
}
....
public class Utils
{
final static private Category log =
Category.getInstance("cb.utils.Utils");
public static void setErrOut(Category cat)
throws IOException
{
PrintStream prtout = new PrintStream(
new LoggingOutputStream(
cat,
Priority.INFO), true);
PrintStream prterr = new PrintStream(
new LoggingOutputStream(
cat,
Priority.ERROR), true);
System.setErr(prterr);
System.setOut(prtout);
}
...
}
I hope it helps.
Zsolt
Ceki G�lc� wrote:
>
> Welcome to the world of Java. Java has gives no guarantees on the ordering of
>threads. The creation of the LoggingEvent and its logging are not atomic. It is
>possible for Thread-12 to create the logging event at 16:28:17,711, loose control to
>Thread-6, have thread-6 log the message with the timestamp 16:28:50,581, have
>thread-12 regain control and log the message with timestamp 16:28:17,711.
>
> Having said that 39 seconds is a long time for a thread to loose control. More
>importantly, the forth message has the time stamp 16:28:17,893 which completely
>debunks the my argument given above.
>
> Can you describe your environment? Does the output come from different clients? Are
>there multiple JVMs writing to the same log file? Which version of log4j is this? Ceki
>
> At 16:37 30.05.2001 +0200, you wrote:
> >Hi,
> >
> >here I attach the log (cb.log) and configuration (log.cfg) files. The
> >second line of the log file was written at '16:28:50,581' and the next
> >line at '16:28:17,711'. I do know that the timestamps are ok. I thought
> >that the log will always appended to the end of the log file.
> >
> >Do I misunderstand something?
> >
> >
> >--
> >Zsolt Koppany
> >Intland GmbH www.intland.com
> >Schulze-Delitzsch-Strasse 16
> >D-70565 Stuttgart
> >Tel: +49-711-7221873 Fax: +49-711-7871017
> >2001-05-30 16:28:11,014 [main] INFO cb - Startup: Wed May 30 16:28:11 CEST 2001
> >2001-05-30 16:28:50,581 [Thread-6] INFO show.gif - show giffile
>/tmp/dmg0nus3k2_991232924522.gif
> >mber of connections: 1
> >2001-05-30 16:28:17,711 [Thread-12] DEBUG cb.db - INSERT DELAYED INTO
>ise_projects.statistic VALUES('','localhost','Project list',NOW(),NULL)
> >2001-05-30 16:28:17,893 [Thread-12] DEBUG cb.db - SELECT DISTINCT
>databasename,DATE_FORMAT(creation_datetime,'%b %d %T
>%Y'),created_by,created_from_host,IFNULL(description,' '),IFNULL(access,'Public'),IFNULL(category,' '),UPPER(databasename)
> AS udb FROM ise_projects.existing WHERE databasename
>IN('cb_','ise_','jedit_2_1','swing_') AND (access='public' OR access IS NULL) ORDER
>BY udb
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> Ceki G�lc�
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Zsolt Koppany
Intland GmbH www.intland.com
Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart
Tel: +49-711-7221873 Fax: +49-711-7871017
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]