B4J Library log4j - Enable logging at runtime without modifying the application binary.

Dear all,

I have written a wrapper for the Apache log4j 1.2 . Unzip the file, copy the files under of lib folder, to your additional folder and check on the libs list, the "tsLogger".

Below you will find the documentation :

B4X:
'-------------------------------------------------------------------------------------------------------------------
class tsLogger
'-------------------------------------------------------------------------------------------------------------------

'Properties

'Readonly Property : Returns true if the class has initialized
tsLogger.IsInitialized

'Readonly Property : Check whether this category is enabled for the DEBUG Level
tsLogger.IsDebugEnabled

'Readonly Property : Check whether this category is enabled for the INFO Level
tsLogger.IsInfoEnabled

'Readonly Property : Check whether this category is enabled for the WARN Level
tsLogger.IsWarnEnabled

'Readonly Property : Check whether this category is enabled for all Level
tsLogger.IsAllEnabled

'Readonly Property : Check whether this category is enabled for the ERROR Level
tsLogger.IsErrorEnabled

'Readonly Property : Check whether this category is enabled for the FATAL Level
tsLogger.IsFatalEnabled

'Readonly Property : Check is logger is disable
tsLogger.IsOffEnabled

'Methods

'Set the level of logger. Parameter: 0 : Off (Default Value) 1 : Trace 2 : Debug 3 : Info 4 : Warn 5 : Error 6 : Fatal
tsLogger.toLevel( value )

'Log a message object with the DEBUG level.
'Parameter: InputValue - The log data
tsLogger.logsDEBUG( InputValue )

'Log a message object with the ERROR Level
'Parameter: InputValue - The log data
tsLogger.logsERROR( InputValue )

'Log a message object with the FATAL Level
'Parameter: InputValue - The log data
tsLogger.logsFATAL( InputValue )

'Log a message object with the INFO Level
'Parameter: InputValue - The log data
tsLogger.logsINFO( InputValue )

'Log a message object with the WARN Level
'Parameter: InputValue - The log data
tsLogger.logsWARN( InputValue )

'Log a message object with the TRACE Level
'Parameter: InputValue - The log data
tsLogger.logsTRACE( InputValue )

'Shutdown the logger. Notes: If you want to reuse it, you need to execute the initialize function.
tsLogger.release

'Initialize the tsLogger object according to logger configuration.
'Notes: If you do not input a pattern on the configuration, it will use the default pattern ( %d{ISO8601} [%t] %-5p %c %x - %m%n )
'Default configuration values:
'LogFilename logfile.log.
'ConsoleEnable false.
'FileWriter true.
'PatternValue "".
'MaxFileSize 1000.
'BackupFiles 1.
tsLogger.initialize

'-------------------------------------------------------------------------------------------------------------------
class tsLogger.Configuration
'-------------------------------------------------------------------------------------------------------------------

'Properties

'ReadWrite Property : Get or set the backup files rotation
tsLogger.Configuration.BackupFiles

'ReadWrite Property : Get or set the max file size
tsLogger.Configuration.MaxFileSize

'ReadWrite Property : Get or set the pattern value.
tsLogger.Configuration.PatternValue

'ReadWrite Property : Get or set if file logger is enabled
tsLogger.Configuration.IsFileWriterEnable

'ReadWrite Property : Get or set if console is enabled
tsLogger.Configuration.IsConsoleEnable

'ReadWrite Property : Get or set the log filename
tsLogger.Configuration.LogFilename

For more information about the log4j, you can find on http://logging.apache.org/log4j/1.2/index.html

I am waiting your feedback for the next update of this java library
 

Attachments

  • tsLogger.zip
    456.2 KB · Views: 479

jhagerup

Member
Licensed User
Longtime User
Hi,
I've just found your wrapper, nice.
Do you have a newer version with the DailyRollingFileAppender implemented ?
/jan
 
Top