Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tips for testing a Spring SLF4J/Logback logging component  RSS feed

Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

As per the requirements for my current project I have developed a reusable enterprise logging component.
I have created a Spring project (Logging-core) which contains amongst other things : (A Spring Singleton).

In this class I have provided instance methods that wrap each of the available SLF4J logging invocations/overloads.

The Logger instance has a reference to 2 other singleton Spring components :

1. (Spring singleton that monitors a JMS Destination for messages providing application specific configuration for the containing Logger instance)
2. LoggerMessageProducer (Spring singleton that publishes all Log Messages in JSON format to a JMS Destination)

In this project I have a dependency on the SLF4J-api and logback-classic.
I have specified that logback use the JNDI context selector to lookup the contextName.
Each application that intends to use this reusable component needs to provide a JNDI entry for the contextName.

I would like ideas on unit/integration tests that I should create to verify that the component is configured as I intended.

For example :
Should I not create tests to assert that existing application code utilising JCL,JUL or SLF4J has it's calls correctly bridged over slf4j to logback, and if so what should my approach be?
How should I go about testing the JNDI context-selection with multiple applications deployed in the JVM? Should I use something like Arquillian? (We are deploying to Jetty)
I have not synchronized access to any of the method calls on my Logger singleton... what should I watch out for her?

Thanks in advance for the advice...

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!