We have implemented custom element using Cisco CVP. We are able to achieve logging using audium addtolog function. But We need to know how we can use log4j for logging in our custom java classes. Do we need to modify logging.properties or log4j.xml by adding package name of our custom classes. We would like to know the location on call studio and vxml server if we can change logging.properties or log4j.xml.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hello!
This is a suggestion how a I have implemented log4j:
public class MyCustomCell extends ActionElementBase implements ElementInterface{
static{
PropertyConfigurator.configure("C:\\cfg\\CustomCVPElementLog.properties");
}
static Logger logger = Logger.getLogger(MyCustomCell.class);
...
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to get Log4J working for your custom code, you do no want to or need to adjust CVP's log configurations. Rather, you will need to create your own Log4J .properties or .xml configuration file and put it in the classpath. You can then, in Java, read the file off the classpath without having to use a static file path. So, if the config file were in your classpath, something like this would load it and initialize your configuration without having to keep a static path:
try { |
URL url = ApplicationStart.class.getResource("/MyConfig_log4j.xml");
DOMConfigurator.configure(url);
} catch (Exception e) {
// do something
}
Now, there are several places you can put the file and have it work. The best choice really depends on your requirements. In Studio, you can put it in deploy/java/application/classes inside of your Studio project. That way, it will deploy with your Studio project and be available automatically. That's usually the simplest as it means you don't have to maintain a copy separately on the server. Otherwise, you can place it with your custom jar files on the CVP server itself, just be sure to use the classes subdirectory instead of the lib subdirectory of wherever you are placing it.
A couple more important notes:
1. don't override the root logger unless you want to start messing with CVP's logging as well
2. don't call your file log4j.properties or log4j.xml, give it some other unique name (so you again don't mess with CVP's logging)
3. if you have logging config files in multiple Studio projects, be sure they're not configuring the same logger. Otherwise, the last one to load will override all the ones that came before it
Good luck!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thank you very much Angie.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.