Curt Arnold | 2 Jan 03:27 2009
Picon

Re: Strange NPEs after redeploy

You are most likely encountering a known Tomcat bug where unloaded  
classes can be inadvertently used during static initialization of  
other classes.  There is a patch for Tomcat which has been integrated  
into Glassfish, but there has been no action to integrate it into  
Tomcat.  If you can't apply the patch to Tomcat, you can disable the  
buggy clear references code by setting a system property.

https://issues.apache.org/bugzilla/show_bug.cgi?id=41059
https://glassfish.dev.java.net/issues/show_bug.cgi?id=6637

It has been document in the FAQ for the upcoming log4j 1.2.16, but  
that hasn't been posted to the site.  Here is the content.

       <faq id="unload">
           <question>Why does log4j throw a NullPointerException or
               print a message about NOPLoggerRepository
               when shutting down or restarting under Tomcat or during  
a shutdown
               hook?</question>
           <answer><p>Tomcat will, by default,
              clear all static members when unloading classes.
              Unfortunately, under certain circumstances
              another class may attempt to call log4j after log4j
              has had its private member variables cleared, resulting  
in either
              a NullPointerException (log4j 1.2.14 or earlier) or a  
console
              message (log4j 1.2.15 and later).  The same type of issue
              has been reported during various shutdown hooks (see bug
              <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=40212 
(Continue reading)

laredotornado | 2 Jan 16:25 2009
Picon

ERROR Failed to flush writer, java.io.InterruptedIOException


Hi,

I'm running Java 1.5 on Weblogic 9.2.2 (Solaris 9) and using log4j 1.2.15. 
During the execution of my program, I'm getting this error ...

log4j:ERROR Failed to flush writer,
java.io.InterruptedIOException
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:260)
        at
sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
        at
sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404)
        at
sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:408)
        at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
        at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
        at org.apache.log4j.helpers.QuietWriter.flush(QuietWriter.java:57)
        at
org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:315)
        at
org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:358)
        at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
        at
org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:230)
        at
org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:65)
        at org.apache.log4j.Category.callAppenders(Category.java:203)
        at org.apache.log4j.Category.forcedLog(Category.java:388)
(Continue reading)

Jacob Kjome | 2 Jan 19:04 2009

Re: Strange NPEs after redeploy

Hi Curt,

What does the following mean?...

On 1/1/2009 8:27 PM, Curt Arnold wrote:
> <li>Use per-application copies of log4j, that is remove log4j.jar from
> WEB-INF/lib.</li>

The first part says "use per-application copies of log4j" and then it says "that
is remove log4j.jar from WEB-INF/lib".  From my point of view, those two sentence
fragments contradict one another.  Adding log4j.jar to WEB-INF/lib *is* the
definition of using per-application copies of log4j.  The only two other ways,
both involving putting log4j in a global classloader, would be to run only one
application per appserver or use repository selectors to provided each application
with its own logger repository.

I'm not entirely sure what the recommendation should be here?  I guess I leave it
to you to correct.

Jake
Jacob Kjome | 2 Jan 19:10 2009

Re: ERROR Failed to flush writer, java.io.InterruptedIOException

Does this happen ever single time your log line is called or just sporadically?
You point out that you have enough disk space, but are you running Java with a
user having write permissions?  Is the log file actually being created?

Jake

On 1/2/2009 9:25 AM, laredotornado wrote:
> Hi,
> 
> I'm running Java 1.5 on Weblogic 9.2.2 (Solaris 9) and using log4j 1.2.15. 
> During the execution of my program, I'm getting this error ...
> 
> log4j:ERROR Failed to flush writer,
> java.io.InterruptedIOException
>         at java.io.FileOutputStream.writeBytes(Native Method)
>         at java.io.FileOutputStream.write(FileOutputStream.java:260)
>         at
> sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
>         at
> sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(StreamEncoder.java:404)
>         at
> sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:408)
>         at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
>         at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
>         at org.apache.log4j.helpers.QuietWriter.flush(QuietWriter.java:57)
>         at
> org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:315)
>         at
> org.apache.log4j.DailyRollingFileAppender.subAppend(DailyRollingFileAppender.java:358)
>         at org.apache.log4j.WriterAppender.append(WriterAppender.java:159)
(Continue reading)

Curt Arnold | 3 Jan 06:28 2009
Picon

Re: ERROR Failed to flush writer, java.io.InterruptedIOException


On Jan 2, 2009, at 12:10 PM, Jacob Kjome wrote:

> Does this happen ever single time your log line is called or just  
> sporadically?
> You point out that you have enough disk space, but are you running  
> Java with a
> user having write permissions?  Is the log file actually being  
> created?
>
> Jake
>
> On 1/2/2009 9:25 AM, laredotornado wrote:
>> Hi,
>>
>> I'm running Java 1.5 on Weblogic 9.2.2 (Solaris 9) and using log4j  
>> 1.2.15.
>> During the execution of my program, I'm getting this error ...
>>
>> log4j:ERROR Failed to flush writer,
>> java.io.InterruptedIOException
>>
>>        at java.io.FileOutputStream.writeBytes(Native Method)
>>        at java.io.FileOutputStream.write(FileOutputStream.java:260)
>>        at
>> sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
>>        at
>> sun.nio.cs.StreamEncoder 
>> $CharsetSE.implFlushBuffer(StreamEncoder.java:404)
>>        at
(Continue reading)

Curt Arnold | 3 Jan 06:30 2009
Picon

Re: Strange NPEs after redeploy


On Jan 2, 2009, at 12:04 PM, Jacob Kjome wrote:

> Hi Curt,
>
> What does the following mean?...
>
> On 1/1/2009 8:27 PM, Curt Arnold wrote:
>> <li>Use per-application copies of log4j, that is remove log4j.jar  
>> from
>> WEB-INF/lib.</li>
>

I think I cut and pasted from suggestions on the mailing list.  Tomcat  
deployment issues are not my speciality.  It would be really really  
nice if Tomcat would actually fix this since it has been reported tons  
of times and not just involving log4j and Glassfish is happy with our  
patch.

Please fix, modify or remove as appropriate.  Source is in src/site/ 
fml/faq.fml (or something like that)
Bender Heri | 5 Jan 15:01 2009
Picon

AW: [SPAM (Bayesain Analysis)] - I need to make logging in a complete application - Bayesian Filter detected spam

I am not quite shure what you want to do. Do you want to leave all System.out.println calls in your code? If so,
you do not need log4j to redirect them. Just redirect the System.out Outputstream to a stream of your like.
If you want to use log4j, you have to replace all System.out calls with the appropriate log4j calls, and
configure the desired appenders through the configuration file. 
Heri

-----Urspr√ľngliche Nachricht-----
Von: Ariel [mailto:isaacrc82 <at> gmail.com] 
Gesendet: Freitag, 26. Dezember 2008 15:29
An: log4j-user <at> logging.apache.org
Betreff: [SPAM (Bayesain Analysis)] - I need to make logging in a complete application - Bayesian Filter
detected spam

Hi everybody:

I am newbie with log4j, I have made a distributed and multithreaded application where all the logging is
made displaying de mesagges in the console using System.out.println. Now I want to redirect those
messages to a file to have a trace of all the messages. Is there anyway to telling log4j that all the
System.out messages write them into a file ???
Please could you help me ?
Regards
Ariel
amitshinde | 6 Jan 12:12 2009

SMTPAppender not asynchronous using AsyncAppender


Hello Everyone,

I am trying to send asynchronous error emails using log4j. I was
successfully able to get the emails but it looks like the emails are
synchronous and block the event processing till the email is sent. This
happens inspite of using AsyncAppender.

I am using SMTPAppender and hooked it up with AsyncAppender (<appender-ref
ref="mail"/>)

Did anyone else notice this? Can we send emails asynchronously at all?

Thanks in advance,

Amit

--

-- 
View this message in context: http://www.nabble.com/SMTPAppender-not-asynchronous-using-AsyncAppender-tp21308582p21308582.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
Michael Erskine | 7 Jan 11:11 2009

RE: I need to make logging in a complete application

> From: Ariel [mailto:isaacrc82 <at> gmail.com]
> Subject: I need to make logging in a complete application
> I am newbie with log4j, I have made a distributed and multithreaded
> application where all the logging is made displaying de mesagges in the
> console using System.out.println. Now I want to redirect those messages
> to a
> file to have a trace of all the messages. Is there anyway to telling
> log4j
> that all the System.out messages write them into a file ???

Sure, redirect standard output to PrintStream subclass that does the logging for you: this should get you started...

        // Redirect output
        PrintStream ps = new PrintStream(new StdoutStderrStream(
            new ByteArrayOutputStream()));
        savedStdout = System.out;
        savedStderr = System.err;
        System.setOut(ps);
        System.setErr(ps);

    private class StdoutStderrStream extends FilterOutputStream {
        public StdoutStderrStream(OutputStream s) {
            super(s);
        }
        public void write(byte b[]) throws IOException {
            // log here in threadsafe manner
        }
        public void write(byte b[], int off, int len) throws IOException {
            // log here in threadsafe manner
        }
(Continue reading)

agEE | 8 Jan 00:17 2009
Picon

TimeBasedRollingPolicy with hourly filenames not getting compressed


I am using log4j.1.2.15 and the rollever works fine. But i am not able to get
the files to compress. Has any one succeed in getting the
RollingFileAppender/ TimeBasedRollingPolicy  to work correctly.

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="console" class="org.apache.log4j.ConsoleAppender">

    <layout class="org.apache.log4j.PatternLayout">

    </layout>
  </appender>

  <appender name="ROLL"
class="org.apache.log4j.rolling.RollingFileAppender">

    <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">

    </rollingPolicy>
    <layout class="org.apache.log4j.PatternLayout">

    </layout>
  </appender>
 <root>
    <priority value ="debug" />
    <appender-ref ref="console" />
    <appender-ref ref="ROLL"/>
  </root>
(Continue reading)


Gmane