Monday, April 25, 2016

Mocking with PowerMock and Mockito

The PowerMock extends Mockito and EasyMock frameworks. The vast advantage of the PowerMock is possibility to mock static and final classes and even private methods and members.

This post does not pretend to be a tutorial for the PowerMock. It just gives several examples of how-to-mock with PowerMock and Mockito.

Saturday, April 16, 2016

Testing log4j2 plugins with custom string appender

There is a bunch of appenders in log4j2 ready for use - visit this manual to get the impression.
A custom appender class is not demanded to be implemented as a plugin.

Wednesday, April 13, 2016

The log4j2 configuration naming and other tips

Customizing of log4j2 configuration is a big issue. This post gives just small tips for:
  • log4j2 configuration file naming
  • PatternLayout
  • File rolling

Sunday, April 10, 2016

Using log4j2 filter plugin for a separate errors log

The log4j2 filter controls output to the log. There is a plenty of ready for use filters as described in filters manual.

A filter allows or denies messages according to its filtering criteria. For example, the ThresholdFilter masks messages, which log level is above or beyond the threshold log level.

A filter activation is done with the log4j2 configuration.

Saturday, April 9, 2016

The log4j2 ThreadContext with configurable tags

Marking messages with application context tags has a great value for logs analyzing.
A context tag is some application-meaningful data, for example user id, specific application flow etc.

The log4j2 provides mechanism for aggregating tags in context of a thread with the ThreadContext.

Saturday, April 2, 2016

Extending log4j2 format with plugins

The log4j2 PatternLayout has the rich set of the build-in format specifiers and attributes.
A log file of desired format may be produced without a single line of code - just with a configuration file.
If the build-in format solutions are not sufficient for particular needs, the log4j2 plugins allow extending of the logging patterns.

About the author

My Photo
I trust only simple code and believe that code should be handsome. This is not a matter of technology, but professional approach, consolidated after years of software development. I enjoy to cause things working and feel very happy, when I manage to solve a problem.
Back to Top