MicroStream Reference Manual
MicroStream HomeAPI Docs
2.2
2.2
  • Preface
  • System Requirements
  • License
  • Changelog
  • Installation
  • Data-Store
    • Overview
    • Getting Started
    • Root Instances
    • Configuration
      • Properties
      • Storage Files and Directories
      • Using Channels
      • Housekeeping
      • Backup
      • Lock File
    • Storing Data
      • Convenience Methods and Explicit Storing (Transactions)
      • Lazy and Eager Storing
      • Transient Fields
      • Best Practice
    • Loading Data
      • Lazy Loading
        • Touched Timestamp, Null-Safe Variant
        • Clearing Lazy References
    • Deleting Data
    • Queries
    • Application Life-Cycle
    • Legacy Type Mapping
      • User Interaction
    • Backup Strategies
    • Import / Export
    • Housekeeping
    • FAQ
      • Data Model
      • Data Management
      • File Storage
      • Environment
      • Miscellaneous
    • Customizing
      • Custom Type Handler
      • Custom Legacy Type Handler
      • PersistenceEagerStoringFieldEvaluator
  • Basic Concepts
    • Layered Entities
      • Configuration
      • Defining Entities
      • Creating Entities
      • Updating Entities
      • Versioning
      • Logging
      • Multiple Layers
    • Wrapping
      • Configuration
      • Usage
Powered by GitBook
On this page
Export as PDF
  1. Basic Concepts
  2. Layered Entities

Logging

PreviousVersioningNextMultiple Layers

Last updated 3 years ago

This is the manual for older MicroStream versions (Version < 5.0).

The new documentation (Version >= 5.0) is located at:

Another predefined logic layer is for logging purposes. Since there is a myriad of loggers out there, MicroStream doesn't provide any special adapter, but a generic type which can be used to adapt to the logging framework of your choice.

Just create a class and implement EntityLogger, and you are good to go.

public class JulLogger implements EntityLogger
{
	@Override
	public void afterUpdate(
		final Entity identity, 
		final Entity data, 
		final boolean successful)
	{
		Logger.getLogger(identity.getClass().getName())
			.info("Entity updated");
	}
}

Additional to afterUpdate there are further hooks:

  • entityCreated

  • afterRead

  • beforeUpdate

Now just add the logger when creating entities:

JulLogger logger = new JulLogger();

Person john = PersonCreator.New()
	.addLayer(logger)
	.firstName("John")
	.lastName("Doe")
	.create();

When you call

PersonUpdater.setLastName(john, "Smith");

the logger's output is

Oct 15, 2019 11:17:53 AM JulLogger afterUpdate
INFO: Entity updated
https://docs.microstream.one/