문제

I've got a java server launched from a jar that uses log4j (RollingFile and Console appender). Alone: no problem it works. I've got a JBoss server using log4j (default install). Everything is ok when it runs alone.

When I start my Java server first and the JBoss, no problem either.

However when launching JBoss first and THEN launch the java server, the last doesn't log anything and JBoss sends me this : ERROR [ServerThread] Failed to initialize

java.io.EOFException
        at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2297)
        at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2766)
        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:797)
        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:297)
        at org.jboss.invocation.pooled.interfaces.OptimizedObjectInputStream.<init>(OptimizedObjectInputStream.java:147)
        at org.jboss.invocation.pooled.server.ServerThread.dorun(ServerThread.java:265)
        at org.jboss.invocation.pooled.server.ServerThread.run(ServerThread.java:156)
log4j:WARN Detected problem with connection: java.net.SocketException: Broken pipe

Is there possible conflict between two servers using LOG4J ? I didn't find anything on the net.

Thanks

ADDENDUM

  • JBoss and the Java server are in different directories
  • JBoss and the Java server don't share any port (8080/8433--> JBoss and 20400-->Java)
  • JBoss and the Java server have their own log4jxxxx.jar in their own library folder
  • Java Log4j version : log4j-1.2.16.jar (I also tried 1.2.17)
  • JBoss version : jboss-5.1.0.GA
  • Both write in different files

Here are the config files : (Basically console & appender file only)

Java

      <!--  mocutil import -->
        <appender name="mocutilImport" class="org.apache.log4j.RollingFileAppender">
                <param name="Threshold" value="INFO" />
                <param name="File" value="log/mocutilImport.log" />
                <param name="MaxFileSize" value="5000KB" />
            <!-- Keep five backup file -->
            <param name="MaxBackupIndex" value="5"/>
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %-5p - %m%n" />
                </layout>
        </appender>
        <appender name="NectarMotrServer" class="org.apache.log4j.RollingFileAppender">
                <param name="Threshold" value="INFO" />
                <param name="File" value="log/NectarMotrServer.log" />
                <param name="MaxFileSize" value="5000KB" />
            <!-- Keep five backup file -->
            <param name="MaxBackupIndex" value="5"/>
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %-5p - %m%n" />
                </layout>
        </appender>
        <appender name="NectarMotrServerDev" class="org.apache.log4j.RollingFileAppender">
                <param name="Threshold" value="DEBUG" />
                <param name="File" value="log/NectarMotrServerDev.log" />
                <param name="MaxFileSize" value="5000KB" />
            <!-- Keep five backup file -->
            <param name="MaxBackupIndex" value="5"/>
                <layout class="org.apache.log4j.PatternLayout">
                        <param name="ConversionPattern" value="%d %c{1} [%t] %p - %m%n" />
                </layout>
        </appender>
    <!--  Default  -->
        <appender name="console" class="org.apache.log4j.ConsoleAppender">
                <param name="Threshold" value="TRACE" />
           <param name="Target" value="System.out"/>
           <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="[%d] %c{1} - %m%n" />
           </layout>
         </appender>
    <category name="fr.edf.nectar">
            <appender-ref ref="NectarmotrServer"/>
            <appender-ref ref="NectarmotrServerDev"/>
            <appender-ref ref="console"/>
    </category>
    <category name="fr.edf.nectar.interfaces.motr.imports.mocutil">
            <appender-ref ref="mocutilImport"/>
    </category>

     <root>
        <priority value="ALL"/>
     </root>

JBOSS (I removed commented appenders)

   <!-- ======================= -->
   <!-- Setup the Root category -->
   <!-- ======================= -->
   <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/server.log"/>
      <param name="Append" value="true"/>
      <!-- In AS 5.0.x the server log threshold was set by a system
           property. In 5.1 and later we are instead using the system
           property to set the priority on the root logger (see <root/> below)
      <param name="Threshold" value="${jboss.server.log.threshold}"/>
      -->

      <!-- Rollover at midnight each day -->
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>

      <!-- Rollover at the top of each hour
      <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
      -->

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] (Thread) Message\n -->
         <param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n"/>

         <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
         <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
          -->
      </layout>
   </appender>
   <!-- ============================== -->
   <!-- Append messages to the console -->
   <!-- ============================== -->

   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Target" value="System.out"/>
      <param name="Threshold" value="INFO"/>

      <layout class="org.apache.log4j.PatternLayout">
         <!-- The default pattern: Date Priority [Category] Message\n -->
         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
      </layout>
   </appender>

   <root>
      <!--
         Set the root logger priority via a system property. Note this is parsed by log4j,
         so the full JBoss system property format is not supported; e.g.
         setting a default via ${jboss.server.log.threshold:WARN} will not work.
       -->
      <priority value="${jboss.server.log.threshold}"/>
      <appender-ref ref="CONSOLE"/>
      <appender-ref ref="FILE"/>
   </root>
도움이 되었습니까?

해결책 2

Here is what happened (Thanks to David Oliván Ubieto for his help):

In the Java server, we're using a Php/Java bridge, looking at its class I found :

Util.Logger()
      Use chainsaw, if available or a default logger.

Refering to David Chainsaw might be a problem, and it does because it uses the port 4445 which is the same as JBoss invoker, type=pooled service (Source).

So what happen I think is that launching the server, the bridge library try connecting to 4445 to see if chainsaw is present. It detects something and decide to use 4445 as Logging port resulting in no log for Java, meanwhile JBoss receives strange messages on 4445 and throw an Exception.

Launching Java first, will result in the lib using my Log4j configuration and JBoss working as expected.

To correct everything I modified .../jboss-5.1.0.GA/server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml like this :

...
        <!-- Pooled invoker -->
        <bean class="org.jboss.services.binding.ServiceBindingMetadata">
           <property name="serviceName">jboss:service=invoker,type=pooled</property>
           <property name="port">[PORT OTHER THAN 4445]</property>
           <property name="description">Socket for the legacy Pooled invoker</property>
        </bean>

...

다른 팁

There is no problem having several applications running in the same machine and using Log4j facilities. The questions is, where is located the Log4j config file in both server? where is Log4j generating the log files in both servers? What appenders are you using? Any point in common can cause problems. Try to isolate both servers with separate config files, log files generated in different folders and both servers having its own copy of Log4j jar.

The error shown is strange as refers to sockets. Log4j uses any appenders that relies on sockets? Any GUI tool for monitoring log like Chainsaw?

Provide more information about the Log4j installed in both servers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top