cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3183
Views
0
Helpful
0
Comments
cdnadmin
Level 11
Level 11
This document was generated from CDN thread

Created by: null on 24-01-2006 06:36:30 PM
Hi,

I have a number of custom action elements hooked into Audium Call Services that send XML requests to an XML gateway and receive information back and then parse the XML - things like customer account verification and so on. This is XML byte streams on a socket - not XML over HTTP.

I have custom logging from within the action element, but the customer would like certain critical errors (e.g. when both of the two XML gateways cannot be contacted) to generate an error to the Windows Event Log as this is being monitored via services from Inteq and support staff would be automatically alerted.

I have a test class that incorporates the basics of NT logging using log4j (and yes, the .DLL is installed in WINNT\system32), but when I put similar code inside the action element, with the log4j.jar in the correct place for Tomcat, instead of seeing the event in the Event Viewer I see a message written on the console window of Tomcat. Tomcat is NOT running as a service.

Can you offer any explanation of this behaviour - for example, do you know if Tomcat has some hooks into log4j (it also comes from the Apache Software Foundation)?

Are there any multi-threading issues when connecting to a log4j logger from within Call Services?

Alternatively, have you come across this requirement previously and have you provided guidance on solving this in another way?

Regards,
Geoff

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: null on 27-01-2006 05:46:43 PM
I've been back to this one a couple of times, and now have more information. Although there have been no replies I can see that there have been a couple of Views on this thread, so some may be interested. ;-)

First of all, I had to supply a "log4j properties" file. Since the Audium Call Services I am using is through Cisco CVP, the version of Tomcat is 4.1 and the log4j.properties file needs to be placed in Tomcat 4.1\common\classes.

The properties file says:

log4j.rootLogger=WARN,A
log4j.appender.A=org.apache.log4j.nt.NTEventLogAppender
log4j.appender.A.layout=org.apache.log4j.PatternLayout

This says I want to log ERROR and WARN to appender A, and appender A is using the Event Log. A PatternLayout is required.

Now when Tomcat starts up I don't have any of the issues I originally posted about, and it's working as it was before I introduced log4j.

Note that I have put two JARs into Tomcat 4.1\common\lib - commons-logging.jar, and (of course) log4j-1.2.13.jar.

In fact, if I start tomcat and while it's running, start another one I actually get an Error event in the Windows Event Viewer - which is certainly progress in the right direction.

However, when I do call to log to the Event Viewer through log4j and the JNI DLL that it uses, I get this interesting message:

com.audium.server.AudiumException: Native Library C:\WINNT\system32\NTEventLogAppender.dll already loaded in another classloader
at com.audium.server.voiceElement.ActionElementBase.service(Unknown Source)
at com.audium.server.controller.Controller.int(Unknown Source)

Can you help me control this?

Regards,
Geoff

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: Michael Bochynski on 30-01-2006 11:43:43 PM
Hi Geoff,

I am glad that you (almost) have it working. However, this issue is not related to Audium software and it is outside of our Support.

With that said, we are not aware of any special ties between Tomcat and log4j. Note that Apache Software Foundation maintains lots of libraries and tools, some of them overlapping.

Note that Audium Call Services ships with log4j library as well. While it might not be the cause of your error, you might look into this as well.

Here is a post from log4j-user group, maybe it will helpful:

http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00924.html

If you need our help with this issue, please contact your Account Manager.

Regards,
Michael

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: null on 31-01-2006 12:52:51 AM
Note that Audium Call Services ships with log4j library as well. While it might not be the cause of your error, you might look into this as well.[/quote:ab2db6d434]
The link was not that useful - I had probably read it as I trolled Google extensively on the topic. But it does have something - and that was the original poster trying to have different log4j XML files under diferent WEB-APP directories. Why there? I had nothing there.

But the fact that Audium Call Services ships with log4j was very interesting. In fact, it was pivotal.

I did not realize that you shipped with the log4j.jar, as it wasn't obvious. In fact, when I read your post I had to search for it. I thought you may have been talking about a recent version of Call Services.

Much to my surprise, I found it - for my CVP install it's in ..\Tomcat 4.1\webapps\CVP\WEB-INF\lib; so no wonder I had not noticed it. I have not had to look in this directory at all when incorporating all sorts of custom Java classes and very heavy duty jars.

I use the Sun Java Web Services JAXB compiler and generated classes to enable custom Audium Action Elements to go from Java classes to XML requests, and XML responses to Java classes. This architecture is pretty complex and I thought I knew where all things (class files, JARs etc) should go. Obviously not - I still have a lot to learn.

Anyway, the good news Michael is that I removed log4j.jar from this directory, since I have log4j-1.2.13.jar in Tomcat\common\lib, and now I can throw WARN and ERROR to the Windows Event Log. Do you imagine I can cause any side effects?

Can you spell "STOKED"? Thanks so much. I love this place.

I'm so excited to have this working. If anyone is interested and is having trouble making it fly, I'm here to help.

Regards,
Geoff

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: Michael Bochynski on 31-01-2006 05:28:47 PM
Geoff,

The Knowledge Base article Using log4j in custom code results in errors describes the log4j issue.

Hope it helps,
Michael

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: null on 31-01-2006 08:38:36 PM
Looks good Michael. I can safely discard the log4j.jar in ..\Tomcat 4.1\webapps\CVP\WEB-INF\lib. Thanks.

Regards,
Geoff

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: Michael Bochynski on 31-01-2006 08:44:18 PM
Geoff,

This library, while not used directly by Audium software is required by Mandarax library. Mandarax is used by Audium to parse XML Decisions. Hence, if you do not use XML in the Decision element, but use Java instead, you should be safe. However, I still suggest testing the application before going into production stage.

Regards,
Michael

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: null on 01-02-2006 02:47:56 PM
Michael,

Thanks once again for following this thread. Your advice is always appreciated.

I do use a number of XML Decision Elements. I am developing the application on a lab system, and the decision elements are working correctly.

Since I have made the classes and methods of log4j available to Tomcat by hooking in a later version of the jar at a higher level, I would think that this would make those classes and methods available to the applications as well.

Would this not be so?

Subject: RE: Writing to Windows Event Log from custom Java action element using log4
Replied by: Michael Bochynski on 23-02-2006 10:35:08 PM
Geoff,

You are correct. Placing your library, log4j or any other, higher in the CLASSPATH will make it available for the loaded applications.

Note that we strongly suggest testing your configuration before going into production.

Regards,
Michael
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links