Skip to content

This project is an exploration of a slick way to test/validate a logging framework without the complexity of having to open a file in the filesystem to read the logfile contents in order to verify the expected log output.

License

Notifications You must be signed in to change notification settings

steve-afrin/java-log-tester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Log Tester

This project is just a personal side project to explore how testing the logging of messages might be testable in a Spock test class. Normally logging is done to either stdout (a.k.a. the console) where console output can be redirected to and captured in a named file or to files, but then opening the application log files and parsing through them in a Java or Groovy test class to validate specific log messages were written in a specific manner can be quite involved.

This project attempts to provide an answer to the question "isn't there an easier way to test logging in a Java application?" I'm not so vain as to say that this solution is necessarily the best implementation or approach for testing logging. I'm sure there are othe ways that could potentially be more effective, but this was just one approach I thought to take to solve the problem. If you have a better way of doing it, I'd love to hear your approach!

This side project was a great way for me to take myself deeper into the Logback framework and explore how to develop customized Appender classes. This project was also a great way for me to explore the relationships of Layout, Encoder, Context, Logger, and Appender classes and how they all collaborate to provide the fundamental basics for being able to configure some pretty complex logging solutions.

To use any of this code in another project, the StringAppender class would necessarily need to be copied to and included in your other project where you want to declare a StringAppender instance and assign it to any Logger configurations.


Here are some of the references I used to help develop this project and better understand the Logback framework:

About

This project is an exploration of a slick way to test/validate a logging framework without the complexity of having to open a file in the filesystem to read the logfile contents in order to verify the expected log output.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published