2 Replies Latest reply on Jun 2, 2014 2:07 PM by rgiordanizz

    Bundle specific log4j.properties

    gsehgal1

      Is there a way to have bundle specific log4j.properties. I have a bundle which needs to log a lot of data and therefore I plan to use RollingFileAppender and write to a specific location. Though when I place the log4j.properties inside the bundle and use the PropertiesConfigurator to load the properties it does not seem to load the log4j.properties.

       

      Is there any ways in JBoss Fuse; such that we can use bundle specific log4j.properties.

       

      Cheers!

      Gaurav

        • 1. Re: Bundle specific log4j.properties
          ffang

          Hi,

           

          You shouldn't have specific log4j.properties for each bundle.

          All logging stuff should be delegated to pax-logging which is a OSGi loging service, that said,  there's a central file $FUSE_ESB/etc/org.ops4j.pax.logging.cfg  where you can configre the logging stuff.

          In this file you can define a customer file appender which could be used for your specific bundles, something like

           

          # Customter File appender

          log4j.appender.myout=org.apache.log4j.RollingFileAppender

          log4j.appender.myout.layout=org.apache.log4j.PatternLayout

          log4j.appender.myout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n

          log4j.appender.myout.file=${karaf.data}/log/my.log  #or anywhere you want

          log4j.appender.myout.append=true

          log4j.appender.myout.maxFileSize=1MB

          log4j.appender.myout.maxBackupIndex=10

           

          then add

          log4j.category.package_for_your_specific_bundle=INFO, myout

           

          And there is a related discussion[1], you may wanna take a look to get more details.

           

          [1]
          http://servicemix.396122.n5.nabble.com/How-to-change-logging-level-for-particular-component-in-servicemix-td5716633.html

           

          Freeman

           

          • 2. Re: Bundle specific log4j.properties
            rgiordanizz

            Hi,

            I'm trying to find some information to configure org.ops4j.logging.cfg on Jboss Fuse 6.1 to send container logs to my remote logstash server , but I found only some forum that talk about this.

            One is http://joelholder.com/author/jclosure/ but in this example the logstash agent is locally so they will use local file as input.

            So reading in some post I've found this configuration

            log4j.appender.server=org.apache.log4j.net.SocketAppender

            log4j.appender.server.Port=5545

            log4j.appender.server.RemoteHost=x.x.x.x

            log4j.appender.server.ReconnectionDelay=10000

             

            and on logstash config file this section

            input {

               tcp {

                    type => log4j

                    port => 5545

               }

            }

             

            But after restarting the container I didn't found the socket opened to remoteHost :-(

             

            Could someone help me?

             

            Regards,

            Roberto