Logging using Log4j and JMS

Hello All,
I am writing an web application. I am working on logging the application messages asynchronously using JMS. And Log4j for writing the messages.
I need help with following 2 things
1) example showing how to create/use JMSAppender
2) Sending messages to JMS Queue
I am sorry, if you think I have posted the message in inapplicable category.
But since its and web application, I found this thread as better choice :)
Thanks and any help Appreciated !

Hello All,
I am writing an web application. I am working on logging the application messages asynchronously using JMS. And Log4j for writing the messages.
I need help with following 2 things
1) example showing how to create/use JMSAppender
2) Sending messages to JMS Queue
I am sorry, if you think I have posted the message in inapplicable category.
But since its and web application, I found this thread as better choice :)
Thanks and any help Appreciated !

Similar Messages

  • Unable to Generate Logs using Log4j

    Hi All,
    I have a task where i have configure weblogic to generate the logs using log4j instead of the default jdk,
    I changed the logging level implementation in admin server from jdk to log4j
    Then i created a log4j.xml and placed it in the root folder of the domain.
    But the adminserver.log file still shows the logs from default jdk the log4j changes tht i did had no effect on the logs.
    Kindly Help
    Thanks
    Mukul

    Hi ,
    I dont have any log4j.properties defined . Should i define a custom log4j.properties.
    This is how my log4j.xml is :
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration>
    <appender name="FILE" class="org.apache.log4j.FileAppender">
    <param name="File" value="myApp.log"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
    <param name="ConversionPattern" value="%d{ISO8601} %t %-5p %c{2} - %m%n"/>
    </layout>
    </appender>
    <logger name="org.apache">
    <level value="WARN"/>
    </logger>
    <logger name="org.springframework">
    <level value="WARN"/>
    </logger>
    <root>
    <level value="DEBUG"/>
    <appender-ref ref="FILE"/>
    </root>
    </log4j:configuration>
    But this is generating a custom log4j log file but we want the weblogic generated adminserver.log to be generated using the log4j instead of jdk

  • Error in Logging using log4j When deployed in weblogic server

    I have deployed an SOAP based web service application as an war file and used log4j propertiers to do application logging .When i tested the application through a JAVA client the log4j log file has all the application log information but when i deployed it in the weblogic server 10.3.3 and tested it through SOAP UI it gives me just "Run time error exception" in the log4j log file(which is returned in the SOAP response) as against the application logs which i need. I have also added <wls:package-name>org.apache.log4j.*</wls:package-name> in the weblogic.xml and also changwed the logging to the log4j logging in the server ( which was perviously JDK logging) .But still it is not returning the complete application error stack trace in the log4j log file(and also in the weblogic command console) I need to get the application error stack trace in the log4j log file ( and also in the console) so it would be easy to debug the code.
    Please help me out in doing the same.
    thanks in advance

    Noman,
    have you checked that the folder D:\OracleJeveloper\Middleware\jdk160_14_R27.6.5-32 contains the jre?
    Timo

  • Logging using Log4J

    Hi,
    I want to use Log4J to write to the sap log using a Log4J appender. I followed the tutorial from https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/36085e78-0801-0010-678d-8b4e89ddff3c
    but i doesnt work for me. When i check the ear which is deployed to the server, i cant find my log4j.properties file anywhere...i guess that is the problem. I put it in the src folder...i thought it was the correct place, but it doesnt show up in the ear...can anyone help me out?
    Much thanks,
    Hugo Hendriks

    Please don't crosspost. It cuts down on the effectiveness of responses, leads to people wasting their time answering what others have already answered, makes for difficult discussion, and is generally just annoying and bad form.

  • Using socket and JMS protocol in the same logic for OSB

    Hi frnds,
    In my organization...the only communication protocol used is "socket" protocol. However, I want to use JMS protocol to process incoming messages. Can somebody help me figuring out how to go about it.
    Using some nice OSB blogs, I am able to create the JMS connection factory and JMS queues in weblogic. And that works fine when I select the communication protocol as JMS while creating the BS and PS.
    What should be my message flow when the communication protocol used is "socket" for both BS and PS.
    salil

    Hi,
    Make the BS as JMS and the PS as socket, in the PS's flow do a route for the BS... Then if an external call is made to the PS via socket, it will send a messages to a JMS queue...
    Hope this helps...
    Cheers,
    Vlad

  • Porting varray data from one db to another remote db using queues and jms

    We are trying to port a varray from one db to another db using queues and java jms. The varray is embedded in an object type (necessary according to oracle docs). The varray, embed object, and the queues are identical between the 2 dbs. We have used the capabilities in jdeveloper to generate the necessary classes to access the embed object and its payload the varray.
    However, when we attempt this:
    public void publish( com.wgint.sql.EaiType payload )
    throws JMSException, SQLException
    Connection dbConnection = ((AQjmsSession)session).getDBConnection();
    AdtMessage message = ((AQjmsSession)session).createAdtMessage();
    message.setAdtPayload( payload );
    ( (AQjmsTopicPublisher) publisher ).publish( publisher.getTopic(),
    message,
    agents );
    we get a ora-00902 error, invalid datatype. I cannot find a single example on technet or the internet in which someone has done something similar. I do not know if it is feasible or not.
    Steve

    Do you really need JMS to do this? If not, just let the AQ layer propagate your messages from your local to your remote queue. See the online doc how to do this.

  • Using JSF and JMS

    Hello Suners,
    I'm developing a web project using JSF for client side development and EJB for server side development. I need to inject a stateful session bean inside my managed bean in order to send the user entries in a message to a JMS queue which in turn give it to registered MDB for asynchronous requests handling. The problem is once the session bean is initialized from within the managed bean i have a null pointer exception for the QueueConnectionFactory and in turn gives a lifecycle exception for my jsf page. I don't know where i should use my session bean. any help will be deeply appreciated, here is the beans code :
    SessionBean
    @Stateful
    public class StockSessionBean implements StockSession {
         @Resource(name = "jms/QueueConnectionFactory",mappedName = "queueConnectionFactory")
         private ConnectionFactory connectionFactory;
         @Resource(name = "StockHistoryQueue", mappedName = "stockHistoryQueue")
         private Destination stockQueue;
    @Remove
    private void sendUserOptions(UserOptions userOptions) {
              try {
                   Connection connection = connectionFactory.createConnection();
                   Session session = connection.createSession(false,
                             Session.AUTO_ACKNOWLEDGE);
                   MessageProducer producer = session.createProducer(stockQueue);
                   ObjectMessage message = session.createObjectMessage();
                   message.setObject(userOptions);
                   producer.send(message);
                   producer.close();
                   session.close();
                   connection.close();
              } catch (Exception e) {
                   e.printStackTrace();
    }ManagedBean
    @ManagedBean(name = "userInfo")
    @SessionScoped
    public class UserInfo {
    @EJB
    private StockSession stockSession
    public doSubmit(ActionEvent e){
    stockSession.setEmail(email);
    stockSession.setStockName(stockName);
    stockSession.sendUserOptions();
    }MDB
    @MessageDriven(activationConfig = {
              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
              @ActivationConfigProperty(propertyName = "destination", propertyValue = "StockHistoryQueue") })
    public class StockMDB implements MessageListener {
         public StockMDB() {
          * @see MessageListener#onMessage(Message)
         public void onMessage(Message message)
              sendEmail(priceList, userOptions.getEmail());
         }

    nigeldeakin wrote:
    The first thing to ask is whether you are sure that
         @Resource(name = "jms/QueueConnectionFactory",mappedName = "queueConnectionFactory")
         private ConnectionFactory connectionFactory;is valid. Does it work when you use it in other places?No it is not working still giving me NullPointerException for it. I'm using JBoss AS and having hard times deploying a jms queue on it i used an xml file to configure the queue and here is the file
    <?xml version="1.0" encoding="UTF-8"?>
    <server>
         <mbean code="org.jboss.jms.server.destination.QueueService"
              name="jboss.messaging.destination:service=Queue,name=StockHistoryQueue"
              xmbean-dd="xmdesc/Queue-xmbean.xml">
              <depends optional-attribute-name="ServerPeer">
                   jboss.messaging:service=ServerPeer
             </depends>
              <depends>jboss.messaging:service=PostOffice</depends>
         </mbean>
    </server>i think it's not working because i have this null exception for queue factory.

  • How to implement custom logging using log4j in Webcenter Portal Application

    I need to implement custom logging and export it to a new log file in Oracle 11.1.1.5 (Webcenter portal application). Please tell me the steps to implement this functionality.

    Please post questions for WebCenter Portal in it's own forum:
    WebCenter Portal

  • What is better Java Logging or Log4J?

    What is better Java Logging or Log4J and why?

    for my money, log4j has the edge, largely because it doesn't keep a lock on log files when they're not actually being written to. but on the downside, it's another third-party library you have to use. then again, every project I've worked on recently has had it imported anyway via some other third-party library like Spring or Hibernate, so it's there anyway
    but only you can answer "which is more suitable for me"

  • Application specific logging with Log4j on weblogic 8.1

    Hi,
    For a few days now, I have been trying to implement application specific logging using Log4j (1.2.x) for my 3 applications running on the same server (8.1.6). All three application war files are generated from same source. I followed the example of Jboss in setting up the Hierarchy for logging using RepositorySelector. In my case Java class which implements RepositorySelector is loaded through ServletContextListener from jar file placed in WEB_INF/lib folder and log4j.properties file is in WEB-INF folder of each application.
    Independent logging of each application takes place correctly, if the applications are deployed from console. However logging fails if weblogic is shutdown and restarted, in this case logging takes place from 2 classes only implementing filters of each application. Logging from other classes is not taking place. I am spinning my wheels on this and can't seem to figure out what the issue is.
    Thanks for any help...below is the snippet of code
    Sohan
    public static synchronized void init(ServletContext config, String strLogProperties, String webAppName)
    throws ServletException {
    if( !initialized ) // set the global RepositorySelector
    defaultRepository = LogManager.getLoggerRepository();
    RepositorySelector theSelector = new MyRepositorySelector();
    LogManager.setRepositorySelector(theSelector, guard);
    initialized = true;
    Hierarchy hierarchy = new Hierarchy(new RootCategory(Level.DEBUG));
    loadLog4JConfig(config, hierarchy, strLogProperties, webAppName);
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    repositories.put(loader, hierarchy);
    config.setAttribute("hierarchy", hierarchy );
    public LoggerRepository getLoggerRepository() {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    LoggerRepository repository = (LoggerRepository)repositories.get(loader);
    if (repository == null) {
    return defaultRepository;
    } else {
    return repository;
    public void LogInit(ServletContext ctx) throws ServletException {
    System.out.println("\n\n---------------Log4jInit---------------\n\n");
    String strLogProperties = ctx.getInitParameter("Log4JProperties");
    System.out.println("Log4j properties " + strLogProperties);
    String webAppName = ctx.getInitParameter("LogFileName");
    System.out.println("App log File name " + webAppName);
    if (webAppName == null ) {
    webAppName = getWebAppName(ctx);
    System.out.println("Application name = " + webAppName);
    MyRepositorySelector.init(ctx, strLogProperties, webAppName);
    LOG = Logger.getLogger(this.getClass());
    LOG.info("Log message from Log4jInit ServletContextListener");
    System.out.println("\n\n---------------Log4jInit: Complete---------------\n\n");
    }

    Has anyone been able to get around the "Export of object xxx barred" error when
    trying to access the object?
    Thanks,
    Kevin
    "Koua" <[email protected]> wrote:
    >
    I have the same problem when adding listener for COM events. I think
    it's a bug
    in Weblogic. It seems that no one can help.
    Teresa Canales <[email protected]> wrote:
    Hi,
    I am getting the following error. I am not sure how to fix this. I
    looked in everywhere on the admin console and couldn't find anything.
    The following is what I am getting....
    BEA-210000 Apr 14, 2004 11:05:42 AM EDT servicelayertrain
    Error COM Export of object: com.symphonyhealth.user.facade.ejb.User_eecm3e_HomeImpl@2ba3e4
    barred
    Any help would be greatly appreciated.
    Teresa

  • Log4j and Jboss are acting weird

    This question is reagards to Log4j and JBoss and I thought this is the best place to ask this question.
    I am using Jboss 3.2.3. My purpose was to log messages in a seperate file "developer.log" using Log4j. These messages has to be logged in this file only. So in my WAR's folder under WEB-INF/classes I created a file log4j.properties:
    log4j.logger.standard=DEBUG, devlog
    log4j.appender.devlog=org.apache.log4j.RollingFileAppender
    log4j.appender.devlog.File=C:/logs/developer.log
    log4j.appender.devlog.layout=org.apache.log4j.PatternLayout
    log4j.appender.devlog.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%nNow my code :
    import org.apache.log4j.Logger;
    private static Logger log = Logger.getLogger("standard");
    log.debug("a debug message");
    log.info("a info message");
    log.warn("a war message");I test run this code without Jboss and it works perfect. It created a file "developer.log" in the desired location and logs messages in it.
    Now i run with JBoss. JBoss does not create "developer.log" file at all. Instead it logs all the messages in server.log
    2005-09-30 23:07:35,459 DEBUG [standard] a debug message
    Jboss is recognizing that it is standard but after that it is not gving me the desired results. Any input on how to fix this problem?
    TIA

    You can tell it you don't want to inherit, by adding
    this to your "standard" category tag:
    <category name="standard" additivity="false">
    thanks. it works perfect.
    ok i got it working kind of. Jboss already comeswith
    a log4j.xml so i put my log4j stuff in this file :You should be able to deploy your own log4j.xml with
    your app's resource files and make it use yours when
    it is running your app.Ok I took out my stuff from Jboss log4j.xml, create a new xml progtest.log4j.xml like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
      <appender name="DEVLOG" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="${jboss.server.home.dir}/log/developer.log" />
        <param name="Append" value="true" />
        <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
        </layout>
      </appender>
      <category name="standard" additivity="false">
        <priority value="INFO"/>
        <appender-ref ref="DEVLOG" />
      </category>
    </log4j:configuration>My web application is in a ProgTest.WAR folder. I put the above file "progtest.log4j.xml" under WEB-INF/classes in ProgTest.WAR folder. When i run the app the very first problem again arises that no developer.log file was created; instead the concerned messages were put into server.log and console.
    All my classes are in one jar file. I include progtest.log4j.xml in that jar file, redeploy it and test it but still the same problem.
    What i am doing wrong here?
    Thanks

  • Using Log4j with Listener

    We are using Log4j and all of our logging files are properly created by a
    listener that starts once our application is deployed. All logging works
    fine when we are running in single server mode but when we deploy the EAR to
    a cluster, the listener starts and we see the log files created and there is
    an initial line written into one of the created log files by the listener.
    When we access our application on the cluster non of the logging messages
    are written out to the files. I am thinking that maybe the listener is
    dieing but I am not sure. We have a log4j config file that is included in
    our WEB-INF directory.
    Is there a way to see what listeners are running?
    Has anyone used log4j in a clustered environment?
    Thanks
    Michelle

    We have managed to get a little further. When the managed servers are
              started up by the admin server, and application is deployed, the log files
              are created by the listener BUT when we access the application nothing is
              written to the logs. We have not located any exceptions, the logs just
              don't seem to get written to. Now, if redeploy the application it properly
              logs to the log files. Any ideas??? Again, our log4j config file is in
              the WEB-INF directory in the EAR and the web.xml has an entry for
              log4j-init-file pointing to the WEB-INF log4j file. We have deployed our
              application to production and I just don't like the fact that if the servers
              must be rebooted that our application must be redeployed. If this step is
              missed then we won't be logging and of course troubleshooting goes out the
              window. Any help greatly appreciated
              I will have to double check if we have a try catch block. If not I will do
              this pronto.
              <Srinagesh Susarla> wrote in message news:[email protected]..
              > log4j should work the same both on single server as well as clustered env.
              > Can you try adding some debug to your listener to ensure that its getting
              > initialized correctly. Also can you surround it with a try catch block to
              > ensure that its getting loaded correctly.
              > Another question: Is this a ServletContextListener or an
              > ApplifecycleListener?
              > If there are any exceptions please post them here.
              >
              > -- Nagesh

  • Using Log4j efficiently

    Hi,
    I've been using Log4j, and I found it a little troublesome to declare an instance variable everywhere and pass the class name to it; like this:
    public class UsesLogger {
         Logger logger = Logger.getLogger(this.class);
         public void log() {
              logger.debug("bla bla");
    }So I thought I could create a wrapper class to encapsulate the logger. For instance:
    public class MyLogger {
         public static void log(Class clazz, String message) {
              Logger logger = Logger.getLogger(clazz);
              logger.debug(message);
    }But I also didn't like passing the class object every time I want to log a message. So the following came to my mind:
    public class MyLogger {
         private static Exception ex = new Exception();
         public static void log(String message) {
              ex.fillInStackTrace();
              StackTraceElement[] ste = ex.getStackTrace();
              Logger logger = Logger.getLogger(ste[1].getClassName());
              //I even can add the method name to the message using ste[1].getMethodName()
              logger.debug(message);
    }So the other classes do the following:
    public class UsesLogger() {
         public void aMethod() {
              MyLogger.log("inside aMethod");
    }My question is, is this approach efficient? especially that the ex.fillInStackTrace() method is synchronized, so it might be a bit costly.
    Any ideas?
    P.S: I'm not sure if this is the right thread to post in.

    > > What is troublesome to you about this?
    >
    I'm not really sure, but I didn't like the idea of
    repeating any piece of code anywhere.
    That's a bit dogmatic, in my opinion. I think DRY is a good principle to follow, but declaring a Logger for a particular class isn't what I'd consider repeating code. If a class needs an instance of a Logger, I think it's perfectly appropriate to declare one (or have one injected -- that's for duffymo and the rest of the Spring zealots ;o)...
    > In this case: including the Logger class and defining its variable
    in every class that needs to log anything. That's why
    I thought of an alternative to centralize the access
    to the logger using my own utility class.
    So my question remains: is this approach efficient?
    I know these types of answers are unsatisfying, but it really depends on what criteria you're using to measure efficiency. In this case, I'd say not really. Your utility class is just adding another layer to the logging functionality. If you think you'll be changing logging frameworks often, it might be beneficial from a design standpoint to abstract out the logging, but I'd be surprised if you'd actually change the underlying logging implementation enough to warrant the new layer. I believe the impact is negligible to nonexistent from an application performance standpoint, but you could always measure it if you wanted.
    But there are other options such as AOP, that may be able to provide you with "cross-cutting" logging functionality you're looking for without sullying your class definitions with logging code.
    Cheers!
    ~

  • How to use log4j in struts project

    Hi, all
    I want to use log4j and pooling in my running project based on struts-tomcat.
    Can any one tell me all the process in details step by step,to apply in my project
    i m wait for any rply

    Another day, another jargon-dump

  • WAS and JMS Message Server

    Does WAS provide a JMS messaging server (as distinct to just the JMS J2EE interface)? If I want to use WAS and JMS do I need to provide my own server or is it part of WAS?

    Hi Rick,
    Yes, SAP Web AS comes with a JMS messaging server (called JMS provider). For more information please refer to the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/a3/63af1bbf09469fa1615c05f0daff6f/frameset.htm">Development Manual</a> or <a href="http://help.sap.com/saphelp_nw04/helpdata/en/90/57849e5e3e45d784afc4e3bfa8136f/frameset.htm">Administration Manual</a>
    Hope that helps!
    Vladimir

Maybe you are looking for