

It is a PatternFlattener with a default pattern. If you don't even want to construct a pattern, ClassicFlattener is for you. Imagine there is a log, with DEBUG level, "my_tag" tag and "Simple message" message, the flattened log would be as below. All you need to do is just passing a pattern with parameters to the flattener.ĭate in default date format "yyyy-MM-dd HH:mm:ss.SSS" We have defined a PatternFlattener, which may satisfy most of you. Log elements(date, time, level and message) should be flattened to a single string before being printed to the file, you need a Flattener to do that. Base on global Logger, change tag to "TAG-A".īy default, a ChangelessFileNameGenerator with log file name log is used.consolePrinter,Īfter initialization, a global Logger with the global config is created, all logging via XLog will pass to this global Logger.īesides, you can create unlimmited number of Logger with different configs: init( // Initialize XLog config, // Specify the log configuration, if not specified, will use new LogConfiguration.Builder().build() androidPrinter, // Specify printers, if no printer is specified, AndroidPrinter(for Android)/ConsolePrinter(for java) will be used. writer( new MyWriter()) // Default: SimpleWriter flattener( new MyFlattener()) // Default: DefaultFlattener cleanStrategy( new FileLastModifiedCleanStrategy( MAX_TIME)) // Default: NeverCleanStrategy() backupStrategy( new NeverBackupStrategy()) // Default: FileSizeBackupStrategy(1024 * 1024)

fileNameGenerator( new DateFileNameGenerator()) // Default: ChangelessFileNameGenerator("log") Builder( "") // Specify the directory path of log file(s) Printer androidPrinter = new AndroidPrinter( true) // Printer that print the log using Printer consolePrinter = new ConsolePrinter() // Printer that print the log to console using System.out Printer filePrinter = new FilePrinter // Printer that print(save) the log to file addInterceptor( new MyInterceptor()) // Add other log interceptor addInterceptor( new BlacklistTagsFilterInterceptor( // Add blacklist tags filter "blacklist1", "blacklist2", "blacklist3")) class, // Add formatter for specific class of object new An圜lassObjectFormatter()) // Use Object.toString() by default borderFormatter( new MyBoardFormatter()) // Default: DefaultBorderFormatter stackTraceFormatter( new MyStackTraceFormatter()) // Default: DefaultStackTraceFormatter threadFormatter( new MyThreadFormatter()) // Default: DefaultThreadFormatter throwableFormatter( new MyThrowableFormatter()) // Default: DefaultThrowableFormatter xmlFormatter( new MyXmlFormatter()) // Default: DefaultXmlFormatter jsonFormatter( new MyJsonFormatter()) // Default: DefaultJsonFormatter enableBorder() // Enable border, disabled by default enableStackTrace( 2) // Enable stack trace info with depth 2, disabled by default enableThreadInfo() // Enable thread info, disabled by default tag( "MY_TAG") // Specify TAG, default: "X-LOG" ALL // Specify log level, logs below this level won't be printed, default: LogLevel.ALL LogConfiguration config = new LogConfiguration.
