Package com.killcoding.log
Class LogRecord
java.lang.Object
com.killcoding.log.LogRecord
The class is write application log
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AlertMessageprivate static Stringprivate static ConfigPropertiesprivate static ByteArrayOutputStreamprivate static PrintStreamprivate static DriverDataSourceprotected static final Stringprivate static Fileprivate static booleanprivate static Stringprivate static Dateprivate static Stringprivate static PrintStreamprivate static PrintStreamprivate static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidAdd log record objectprivate static voidArchive Logprivate static intFor write log to databaseprivate static intFor write log to databaseprivate static voiddeleteFilesOlderThan(File directory, long fileOutArchiveDaysMs) Delete old log fileprivate static intFor write log to databaseFor write log to databasestatic Stringstatic DataSourceGet data sourcegetLogBatch(List<Map<String, Object>> list) protected static SimpleDateFormatGet log date formatprivate static Fileprivate static intgetLogFileIndex(String prefix, String suffix) static Stringprotected static SimpleDateFormatGet log time formatprivate static voidinitDataSource(String loadDatabaseOutDataSource) For write log to databaseprotected static booleanIs started log threadprotected static booleanlist()Set log listprivate static Objectprotected static voidPush log record to alert message list;protected static voidRemove log record objectprotected static voidsetConfig(ConfigProperties _config) Set configprotected static intsize()Get log list sizeprotected static voidstart()Start write log threadprivate static voidwriteLogBatch(Map<String, List<String>> logBatch) For write log to databaseprivate static voidwriteLogBatchToDatabase(List<Map<String, Object>> list) For write log to database
-
Field Details
-
DEFAULT_MESSAGE_FORMAT
- See Also:
-
LOG_RECORD_POOL
-
started
-
firstRefreshConfig
-
level
-
hostname
-
config
-
LAST_REFRESH_CONFIG_TIME
-
appDataSourcePath
-
fileOutFolder
-
dataSource
-
alertMesage
-
alertMessageLevelList
-
originalOut
-
originalErr
-
customOutput
-
customPrint
-
-
Constructor Details
-
LogRecord
public LogRecord()
-
-
Method Details
-
getLogTimeFormat
Get log time format -
getLogDateFormat
Get log date format -
isStarted
Is started log thread- Returns:
- boolean
-
setConfig
Set config- Parameters:
_config-
-
list
Set log list- Parameters:
list-- Returns:
- List<Map<String, Object>>
-
size
Get log list size -
add
Add log record object -
remove
Remove log record object -
pushAlertMessage
Push log record to alert message list; -
process
-
getLogFileIndex
-
getLogBatch
-
format
-
getLogFile
-
getLogFileName
-
isSystemOut
-
writeLogBatch
For write log to database -
writeLogBatchToDatabase
For write log to database -
initDataSource
For write log to database -
archiveLog
Archive Log -
deleteFilesOlderThan
private static void deleteFilesOlderThan(File directory, long fileOutArchiveDaysMs) throws IOException Delete old log file- Throws:
IOException
-
first
For write log to database- Throws:
Exception
-
execute
For write log to database- Throws:
Exception
-
batchPart
For write log to database- Throws:
Exception
-
batch
For write log to database- Throws:
Exception
-
getDataSource
Get data source- Returns:
- DataSource
-
start
Start write log thread
-