简体   繁体   中英

Logging to log4j log file from webservice server app using Axis2 and Netbeans 7

I'm new to webservice development. I'm using Netbeans 7.0 with the Axis2 plugin and Tomcat 7.

I have a server application that is just a bunch of web methods with no UI or anything, and I created it pretty much following the tutorial at http://netbeans.org/kb/69/websvc/gs-axis.html . I use the Axis2 plugin to deploy to Tomcat.

So when I created my server application, there is no main method or anything. Typically if I want to log to a log4j log file, I'd put something like this in my main method to define where the config file for log4j resides...

PropertyConfigurator.configure("./conf/log4j.properties");

I do this on the webservice client and it works just fine, but of course that has a main method. So where would I put it in a webservice server application that has no main method? I know it doesn't have to be in the main method, but it has to be in some block of code that I know will execute, and I can't really guarantee which of my web methods will be executed first, so I can't really just stick it in one of my web methods.

I did check out other posts on StackOverflow, but didn't really find any that describe what to do in this scenario.

Anyone know the right way to do this?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM