GridJsLogger

Inheritance: java.lang.Object

public class GridJsLogger

Provides a lightweight logging system for GridJs server. Supports console and file output with configurable log levels. Default level is None. In DEBUG build, the default level is Debug (outputs all messages). Supports log file rolling by day/week/month.

Methods

MethodDescription
closeLogFile()Closes the log file writer and disables file output.
debug(String message)Logs a debug level message.
equals(Object arg0)
error(String message)Logs an error level message.
getClass()
getEnableConsoleOutput()Gets whether to output log messages to the console.
getEnableFileOutput()Gets whether to output log messages to a file.
getLevel()Gets the minimum log level.
getLogFilePath()Gets the current log file path, or null if not set.
getMaxFileSize()Gets the maximum size (in bytes) for a single log file before rolling.
hashCode()
info(String message)Logs an info level message.
log(int level, String message)Logs a message at the specified level.
notify()
notifyAll()
setEnableConsoleOutput(boolean value)Sets whether to output log messages to the console.
setEnableFileOutput(boolean value)Sets whether to output log messages to a file.
setLevel(int value)Sets the minimum log level.
setLogDirectory(String directory)Sets the log directory with daily rolling file strategy and enables file output.
setLogDirectory(String directory, int rolling)Sets the log directory with rolling file strategy and enables file output.
setLogDirectory(String directory, int rolling, String filePrefix)Sets the log directory with rolling file strategy and enables file output.
setLogFile(String filePath)Sets the log file path and enables file output (single file mode, no rolling).
setLogFile(String filePath, boolean append)Sets the log file path and enables file output (single file mode, no rolling).
setMaxFileSize(long value)Sets the maximum size (in bytes) for a single log file before rolling.
toString()
wait()
wait(long arg0)
wait(long arg0, int arg1)
warn(String message)Logs a warning level message.

closeLogFile()

public static void closeLogFile()

Closes the log file writer and disables file output.

debug(String message)

public static void debug(String message)

Logs a debug level message.

Parameters:

ParameterTypeDescription
messagejava.lang.String

equals(Object arg0)

public boolean equals(Object arg0)

Parameters:

ParameterTypeDescription
arg0java.lang.Object

Returns: boolean

error(String message)

public static void error(String message)

Logs an error level message.

Parameters:

ParameterTypeDescription
messagejava.lang.String

getClass()

public final native Class<?> getClass()

Returns: java.lang.Class

getEnableConsoleOutput()

public static boolean getEnableConsoleOutput()

Gets whether to output log messages to the console. Default is false.

Returns: boolean

getEnableFileOutput()

public static boolean getEnableFileOutput()

Gets whether to output log messages to a file. Default is false. Must call setLogFile(String) or setLogDirectory(String) before enabling.

Returns: boolean

getLevel()

public static int getLevel()

Gets the minimum log level. Messages below this level will be ignored. Default is None.

See GridJsLogLevel.

Returns: int

getLogFilePath()

public static String getLogFilePath()

Gets the current log file path, or null if not set.

Returns: java.lang.String

getMaxFileSize()

public static long getMaxFileSize()

Gets the maximum size (in bytes) for a single log file before rolling. Only effective when rolling is enabled. 0 means no size limit. Default is 0.

Returns: long

hashCode()

public native int hashCode()

Returns: int

info(String message)

public static void info(String message)

Logs an info level message.

Parameters:

ParameterTypeDescription
messagejava.lang.String

log(int level, String message)

public static void log(int level, String message)

Logs a message at the specified level.

Parameters:

ParameterTypeDescription
levelintGridJsLogLevel. The log level.
messagejava.lang.StringThe message to log.

notify()

public final native void notify()

notifyAll()

public final native void notifyAll()

setEnableConsoleOutput(boolean value)

public static void setEnableConsoleOutput(boolean value)

Sets whether to output log messages to the console. Default is false.

Parameters:

ParameterTypeDescription
valueboolean

setEnableFileOutput(boolean value)

public static void setEnableFileOutput(boolean value)

Sets whether to output log messages to a file. Default is false. Must call setLogFile(String) or setLogDirectory(String) before enabling.

Parameters:

ParameterTypeDescription
valueboolean

setLevel(int value)

public static void setLevel(int value)

Sets the minimum log level. Messages below this level will be ignored. Default is None.

See GridJsLogLevel.

Parameters:

ParameterTypeDescription
valueint

setLogDirectory(String directory)

public static void setLogDirectory(String directory)

Sets the log directory with daily rolling file strategy and enables file output. Log files will be named as: gridjs_{period}.log

Parameters:

ParameterTypeDescription
directoryjava.lang.StringThe directory to store log files.

setLogDirectory(String directory, int rolling)

public static void setLogDirectory(String directory, int rolling)

Sets the log directory with rolling file strategy and enables file output. Log files will be named as: gridjs_{period}.log

Parameters:

ParameterTypeDescription
directoryjava.lang.StringThe directory to store log files.
rollingintGridJsLogRolling. The rolling strategy (Daily/Weekly/Monthly).

setLogDirectory(String directory, int rolling, String filePrefix)

public static void setLogDirectory(String directory, int rolling, String filePrefix)

Sets the log directory with rolling file strategy and enables file output. Log files will be named as: {prefix}_{period}.log Examples: gridjs_2026-07-27.log (Daily), gridjs_2026-W30.log (Weekly), gridjs_2026-07.log (Monthly)

Parameters:

ParameterTypeDescription
directoryjava.lang.StringThe directory to store log files.
rollingintGridJsLogRolling. The rolling strategy (Daily/Weekly/Monthly).
filePrefixjava.lang.StringThe file name prefix.

setLogFile(String filePath)

public static void setLogFile(String filePath)

Sets the log file path and enables file output (single file mode, no rolling). Appends to existing file.

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe full path to the log file.

setLogFile(String filePath, boolean append)

public static void setLogFile(String filePath, boolean append)

Sets the log file path and enables file output (single file mode, no rolling).

Parameters:

ParameterTypeDescription
filePathjava.lang.StringThe full path to the log file.
appendbooleanWhether to append to existing file.

setMaxFileSize(long value)

public static void setMaxFileSize(long value)

Sets the maximum size (in bytes) for a single log file before rolling. Only effective when rolling is enabled. 0 means no size limit. Default is 0.

Parameters:

ParameterTypeDescription
valuelong

toString()

public String toString()

Returns: java.lang.String

wait()

public final void wait()

wait(long arg0)

public final native void wait(long arg0)

Parameters:

ParameterTypeDescription
arg0long

wait(long arg0, int arg1)

public final void wait(long arg0, int arg1)

Parameters:

ParameterTypeDescription
arg0long
arg1int

warn(String message)

public static void warn(String message)

Logs a warning level message.

Parameters:

ParameterTypeDescription
messagejava.lang.String