What is a good logging library for real-time systems (fast without creating an object)?

I tried logback but created a ton of garbage. Has anyone heard of good for Java in real time?


@Bernie: I logged 1M cached messages and GC went crazy.

+4
source share
4 answers

You can take a look at CoralLog , developed by Coral Blocks (with which I am associated), which produces zero garbage and has an average latency of 53 nanoseconds when registering a 64-byte message. In terms of throughput, it can log 2.6 million 64-byte messages per second with time stamps and 3.5 million 64-byte messages per second without time stamps. Full test results can be seen here .

If you reduce the message size to 16 bytes, you can record 5.2 million messages per second without a time stamp.

The following is a simple throughput test:

package com.coralblocks.corallog.bench; import java.io.File; import java.nio.ByteBuffer; import com.coralblocks.corallog.AsyncThread; import com.coralblocks.corallog.Log; import com.coralblocks.corallog.Logger; public class PerformanceTest4 { public static void main(String[] args) throws Exception { int batchSize = Integer.parseInt(args[0]); int passes = Integer.parseInt(args[1]); int msgSize = Integer.parseInt(args[2]); byte[] msgBytes = new byte[msgSize]; // build a dummy message: for(int i = 0; i < msgBytes.length; i++) { msgBytes[i] = (byte) String.valueOf(i % 10).charAt(0); } ByteBuffer bb = ByteBuffer.wrap(msgBytes); Log.setIncludeTopHeader(false); String dir = "."; String filename = "throughput.log"; Logger logger; boolean isMmap = System.getProperty("logMemoryMappedFile", "true").equals("true"); if (isMmap) { logger = Log.createMemoryMappedLogger(dir, filename, null /* no timestamps */, false /* not synchronized */, true /* asynchronous */); } else { logger = Log.createLogger(dir, filename, null, false, true); } int count = 0; while(count < passes) { long start = System.nanoTime(); for(int i = 0; i < batchSize; i++) { bb.position(0); logger.log(bb); } long time = System.nanoTime() - start; double seconds = (((double) time) / 1000000000L); System.out.println("Batch " + (count + 1) + " took: " + seconds + " s"); count++; } logger.drainCloseAndWait(); boolean deleteFile = System.getProperty("deleteFile", "true").equals("true"); if (deleteFile) { File f = new File(dir, filename); f.delete(); } AsyncThread.drainAndDie(); // just so the vm will exit... (async thread is not daemon) } } 
+2
source

I have a library that can write text or binary data in a microsecond without creating garbage or even a system call.

https://github.com/peter-lawrey/Java-Chronicle

The log can also be read in real time using any number of reading processes, providing you with a constant queue that can handle more than 5 million messages per second.

+15
source

Javolution provides logging capabilities.

From LogContext javadoc:

The same code can work using system out / err, standard logging (java.util.logging), Log4J, or even the OSGI logging service. The selection can be made at runtime via configuration ).

(' configuration ' belongs to the Javolution class).

0
source
-3
source

Source: https://habr.com/ru/post/1403968/


All Articles