Date Posted:
Product: TIBCO Spotfire®
Product: TIBCO Spotfire®
Problem:
How to enable custom logging in Custom Authentication or AuthenticationFilter
Solution:
Below are the steps required to add custom logs to custom Custom Authentication or AuthenticationFilter code.
1. Add the "log4j-api.jar" and "log4j-core.jar" to the project. These can be copied from the tomcat\webapps\spotfire\WEB_INF\lib folder
2. In your custom code, import the necessary LogManager and Logger:
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;And at the beginning of the class add:
protected static Logger log = LogManager.getLogger(CustomClassName.class);Resulting in, for example:
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class CustomClassName { protected static Logger log = LogManager.getLogger(CustomClassName.class); ... }
3. Now you can add logging statements in your code using the below statement
log.debug("In CustomClassName");
4. If this class is added to the package name say "com.spotfire" then there is no need of any configuration and you should see the logs being output to the server.log. However if you use another package names say "com.security.customfilter" then you need to add the following to the Log4j2.xml in the tomcat\spotfire-config\ so that the custom logging is output to server.log
<Logger name="com.security.customfilter" level="DEBUG" additivity="false"> <AppenderRef ref="serverlog"/> </Logger>
Comments
0 comments
Article is closed for comments.