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
| Method | Description |
|---|---|
| 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:
| Parameter | Type | Description |
|---|---|---|
| message | java.lang.String |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| arg0 | java.lang.Object |
Returns: boolean
error(String message)
public static void error(String message)
Logs an error level message.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| message | java.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:
| Parameter | Type | Description |
|---|---|---|
| message | java.lang.String |
log(int level, String message)
public static void log(int level, String message)
Logs a message at the specified level.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| level | int | GridJsLogLevel. The log level. |
| message | java.lang.String | The 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:
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
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:
| Parameter | Type | Description |
|---|---|---|
| value | boolean |
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:
| Parameter | Type | Description |
|---|---|---|
| value | int |
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:
| Parameter | Type | Description |
|---|---|---|
| directory | java.lang.String | The 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:
| Parameter | Type | Description |
|---|---|---|
| directory | java.lang.String | The directory to store log files. |
| rolling | int | GridJsLogRolling. 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:
| Parameter | Type | Description |
|---|---|---|
| directory | java.lang.String | The directory to store log files. |
| rolling | int | GridJsLogRolling. The rolling strategy (Daily/Weekly/Monthly). |
| filePrefix | java.lang.String | The 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:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | The 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:
| Parameter | Type | Description |
|---|---|---|
| filePath | java.lang.String | The full path to the log file. |
| append | boolean | Whether 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:
| Parameter | Type | Description |
|---|---|---|
| value | long |
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
| Parameter | Type | Description |
|---|---|---|
| arg0 | long | |
| arg1 | int |
warn(String message)
public static void warn(String message)
Logs a warning level message.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| message | java.lang.String |