SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

LOGGING / NOTES</>↗
Logging17 Mar 2009

How do I create a rolling log files?

In this example we create a rolling or a sequenced of log files. Instead of just limiting the file size (see. How do I limit the size of log file) we can also make the log file to roll. This will prevent a lost to an important log message if we use a single log […]

Wayan · 2 min read
LOGGING / NOTES</>↗
Logging16 Mar 2009

How do I limit the size of log file?

In this example you learn how to limit the size of a log file when using a FileHandler handler. Limiting the log file will prevent the log file to grow wildly without limit. package org.kodejava.util.logging; import java.util.logging.Logger; import java.util.logging.FileHandler; import java.io.IOException; public class LogFileLimit { // The log file size is set to 1 MB. […]

Wayan · 1 min read
LOGGING / NOTES</>↗
Logging12 Mar 2009

How do I create a custom logger Formatter?

To create a custom Formatter we need to extend the java.util.logging.Formatter abstract class and implements the format(LogRecord) method. In the method then we can format the log message stored in the LogRecord to match our need. The java.util.logging.Formatter class also have the getHead(Handler) and getTail(Handler) which can be overridden to add a head and a […]

Wayan · 2 min read
LOGGING / NOTES</>↗
Logging08 Mar 2009

How do I prevent the logger send log messages to its parent logger?

To prevent log records being forwarded to the logger’s parent handlers we can set false the useParentHandlers field using the Logger.setUserParentHandlers(boolean useParentHandlers) method. package org.kodejava.util.logging; import java.util.logging.Logger; import java.util.logging.ConsoleHandler; public class NoParentLogger { public static void main(String[] args) { Logger logger = Logger.getLogger(NoParentLogger.class.getName()); // Do not forward any log messages the logge...

Wayan · 1 min read
LOGGING / NOTES</>↗
Logging07 Mar 2009

How do I set the formatter of logger handlers?

In this example we’ll see how to set the formatter for the logger handlers. We set the formatter by calling the Handler.setFormatter() method. In the code below we set a SimpleFormatter for our FileHandler handler and XMLFormatter for the ConsoleHandler handler. This SimpleFormatter format the log in a plain text information while on the other […]

Wayan · 2 min read
LOGGING / NOTES</>↗
Logging03 Mar 2009

How do I compare Logger Level severity?

In this example we see how we can compare the Level severity between two levels. The Level class has an intValue() method that return the integer value of Level‘s severity. package org.kodejava.util.logging; import java.util.logging.Level; public class LogLevelSeverityCompare { public static void main(String[] args) { Level info = Level.INFO; Level warning = Level.WARNING; Level finest = […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.