简体   繁体   English

使用Axis2和Netbeans 7从Web服务服务器应用程序登录到log4j日志文件

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

I'm new to webservice development. 我是Web服务开发的新手。 I'm using Netbeans 7.0 with the Axis2 plugin and Tomcat 7. 我正在将Netbeans 7.0与Axis2插件和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 . 我有一个服务器应用程序,它只是一堆没有UI或任何东西的Web方法,我是按照http://netbeans.org/kb/69/websvc/gs-axis.html上的教程创建的。 I use the Axis2 plugin to deploy to Tomcat. 我使用Axis2插件部署到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... 通常,如果我想登录到log4j日志文件,我会在主方法中放入类似内容,以定义log4j的配置文件所在的位置...

PropertyConfigurator.configure("./conf/log4j.properties"); 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. 我在webservice客户端上执行此操作,效果很好,但是当然有一种主要方法。 So where would I put it in a webservice server application that has no main method? 那么,我将它放在没有主要方法的Web服务服务器应用程序中的什么位置? 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. 我知道它不必在main方法中,但是它必须在我知道将要执行的某些代码块中,而且我不能真正保证首先执行哪个Web方法,因此我可以并不只是将其固定在我的一种网络方法中。

I did check out other posts on StackOverflow, but didn't really find any that describe what to do in this scenario. 我确实检查了StackOverflow上的其他帖子,但没有真正找到任何描述这种情况的方法。

Anyone know the right way to do this? 有人知道正确的方法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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