Package com.ibm.di.api.syslog
Class LogUtils
- java.lang.Object
-
- com.ibm.di.api.syslog.LogUtils
-
public class LogUtils extends java.lang.Object
Some Logging Utilities
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AL_LOG_DIR_PREFIX
Assembly Line log directory prefixstatic java.lang.String
ROOT_LOG_DIR
Root log directory
-
Constructor Summary
Constructors Constructor Description LogUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
cleanALLogs(java.lang.String aConfigId, java.lang.String aALName, java.lang.String[] logsToBeDeleted)
Deletes all the logs which are specified in "logsToBeDeleted
" array.static void
cleanAllOldALLogs(int aKeepNum)
Cleans all AL logs and leaves only aKeepNum of themstatic void
cleanAllOldALLogs(java.util.Date aMinDate)
Cleans all AL logs created after the given Datestatic void
cleanAllOldLogs(int aKeepNum)
Cleans all logs(AL and EH) and leaves only aKeepNum of themstatic void
cleanAllOldLogs(java.util.Date aMinDate)
Cleans all logs(AL and EH) created after the given Datestatic java.lang.Boolean
cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, int aKeepNum)
Cleans AL logs, for a given config ID and Assembly Line name, and leaves only aKeepNum of themstatic java.lang.Boolean
cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, java.util.Date aMinDate)
Cleans AL logs, for a given config ID and Assembly Line name, created after the given Datestatic java.lang.Boolean
cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, java.util.Date aMinDate, java.util.Date aMaxDate)
Cleans AL logs, for a given config ID and Assembly Line name, created after the given Datestatic java.lang.String
getALLastLogFileName(java.lang.String aConfigId, java.lang.String aALName)
Retrieves the available log names, sorts them in ascending order according to the Natural Ordering and returns the last one.static java.lang.String
getALLog(java.lang.String aConfigId, java.lang.String aALName, java.lang.String aLogFileName)
Retrieves the content of the AL log.static java.lang.String[]
getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName)
Retrieves the available component's log files names.static java.lang.String[]
getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, int iNumber)
Retrieves the specified number of available component's log files names.static java.lang.String[]
getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, java.util.Date dDate)
Retrieves the available component's log files names after the specified date.static java.lang.String[]
getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, java.util.Date startDate, java.util.Date endDate)
Retrieves the available component's log files names after the specified date.static java.lang.String
getALLogLastChunk(java.lang.String aConfigId, java.lang.String aALName, java.lang.String aLogFileName, int aKilobytes)
This method retrieves the specified number of kylobytes from the content of a AL's log file as String.static java.lang.String[]
getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName)
Retrieves the available component's log files in ascending order.static java.lang.String[]
getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName, int number)
Retrieves the specified number of available component's log files sorted in ascending order.static java.lang.String[]
getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName, java.util.Date dDate)
Retrieves the available component's log files after the specified date sorted in ascending order.static java.lang.String
getCleanConfigId(java.lang.String aConfigId)
Replaces '/', ':', '\\', '*', '?', '"', '<', '>', '|' symbols with '_' from the given config idstatic java.lang.String
getComponentLog(java.lang.String aLogFileName)
Retrieves the content of the log file.static java.lang.String
getComponentLogLastChunk(java.lang.String aLogFileName, int aKilobytes)
Retrieves the specified number of kilobytes from the end of the log file.static SystemLogAppender
getSystemLogAppender(Log aLog)
Searches the given Log object for the System Log Appender
-
-
-
Field Detail
-
ROOT_LOG_DIR
public static final java.lang.String ROOT_LOG_DIR
Root log directory- See Also:
- Constant Field Values
-
AL_LOG_DIR_PREFIX
public static final java.lang.String AL_LOG_DIR_PREFIX
Assembly Line log directory prefix- See Also:
- Constant Field Values
-
-
Method Detail
-
getSystemLogAppender
public static SystemLogAppender getSystemLogAppender(Log aLog)
Searches the given Log object for the System Log Appender- Parameters:
aLog
-- Returns:
- the System Log Appender, part of the given Log object, null if not found
-
getComponentLog
public static java.lang.String getComponentLog(java.lang.String aLogFileName) throws DIException
Retrieves the content of the log file.- Parameters:
aLogFileName
- name of log file.- Returns:
- the content of the aLogFileName log file as a String
- Throws:
DIException
- if an error occurs
-
getComponentLogLastChunk
public static java.lang.String getComponentLogLastChunk(java.lang.String aLogFileName, int aKilobytes) throws DIException
Retrieves the specified number of kilobytes from the end of the log file.- Parameters:
aLogFileName
- name of the fileaKilobytes
- number of kilobytes- Returns:
- the last aKilobytes of the content of aLogFileName log file as a String
- Throws:
DIException
-
getALLogFileNames
public static java.lang.String[] getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName) throws DIException
Retrieves the available component's log files names.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line name- Returns:
- a String array containing all the available log files for the components in the given Assembly Line
- Throws:
DIException
- if an error occurs.
-
getALLogFileNames
public static java.lang.String[] getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, int iNumber) throws DIException
Retrieves the specified number of available component's log files names.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line nameiNumber
- how many of the available log files you need- Returns:
- a String array containing containing the first number amount of the sorted by names according to the natural ordering available log files for the components in the given Assembly Line
- Throws:
DIException
- if an error occurs.
-
getALLogFileNames
public static java.lang.String[] getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, java.util.Date dDate) throws DIException
Retrieves the available component's log files names after the specified date.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line namedDate
- the earliest Date for the logs needed- Returns:
- a String array containing available log files for the components in the given Assembly Line which are created after the given Date
- Throws:
DIException
- if an error occurs.
-
getALLogFileNames
public static java.lang.String[] getALLogFileNames(java.lang.String aConfigId, java.lang.String aALName, java.util.Date startDate, java.util.Date endDate) throws DIException
Retrieves the available component's log files names after the specified date.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line namestartDate
- the start Date for the logs neededendDate
- the end Date for the logs needed- Returns:
- a String array containing available log files for the components in the given Assembly Line which are created after the given Date
- Throws:
DIException
- if an error occurs.
-
getALLastLogFileName
public static java.lang.String getALLastLogFileName(java.lang.String aConfigId, java.lang.String aALName) throws DIException
Retrieves the available log names, sorts them in ascending order according to the Natural Ordering and returns the last one.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line name- Returns:
- The last log according to the Natural Ordering of the names
- Throws:
DIException
-
getALLog
public static java.lang.String getALLog(java.lang.String aConfigId, java.lang.String aALName, java.lang.String aLogFileName) throws DIException
Retrieves the content of the AL log.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line nameaLogFileName
- the name of the log file- Returns:
- The content of the Assembly Line log file as String
- Throws:
DIException
- if an error occurs.
-
getALLogLastChunk
public static java.lang.String getALLogLastChunk(java.lang.String aConfigId, java.lang.String aALName, java.lang.String aLogFileName, int aKilobytes) throws DIException
This method retrieves the specified number of kylobytes from the content of a AL's log file as String.- Parameters:
aConfigId
- the ID of the configuration the Assembly Line belongs toaALName
- the Assembly Line nameaLogFileName
- the name of the log fileaKilobytes
- number of kilobytes.- Returns:
- The last aKilobytes from the content of the Assembly Line log file as String
- Throws:
DIException
-
getAvailableComponentLogFiles
public static java.lang.String[] getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName)
Retrieves the available component's log files in ascending order.- Parameters:
aComponentTypeDir
- the component type directoryaConfigId
- the ID of the configuration the Assembly Line belongs toaComponentName
- the component name- Returns:
- a String array containing the sorted into ascending order according to the natural ordering of the names of the available log files for the given component
-
getCleanConfigId
public static java.lang.String getCleanConfigId(java.lang.String aConfigId)
Replaces '/', ':', '\\', '*', '?', '"', '<', '>', '|' symbols with '_' from the given config id- Parameters:
aConfigId
- configuration ID- Returns:
- the modified config name.
-
cleanAllOldLogs
public static void cleanAllOldLogs(java.util.Date aMinDate) throws DIException
Cleans all logs(AL and EH) created after the given Date- Parameters:
aMinDate
- after this date , the log are deleted- Throws:
DIException
- if an error occurs.
-
cleanAllOldLogs
public static void cleanAllOldLogs(int aKeepNum) throws DIException
Cleans all logs(AL and EH) and leaves only aKeepNum of them- Parameters:
aKeepNum
- number of logs to keep.- Throws:
DIException
- if an error occurs.
-
cleanAllOldALLogs
public static void cleanAllOldALLogs(java.util.Date aMinDate) throws DIException
Cleans all AL logs created after the given Date- Parameters:
aMinDate
- after this date , the log are deleted- Throws:
DIException
- if an error occurs.
-
cleanAllOldALLogs
public static void cleanAllOldALLogs(int aKeepNum) throws DIException
Cleans all AL logs and leaves only aKeepNum of them- Parameters:
aKeepNum
- number of logs to keep- Throws:
DIException
- if an error occurs
-
cleanOldALLogs
public static java.lang.Boolean cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, java.util.Date aMinDate) throws DIException
Cleans AL logs, for a given config ID and Assembly Line name, created after the given Date- Parameters:
aConfigId
- configuration IDaALName
- name of the assembly lineaMinDate
- after this date , the log are deleted- Returns:
- whether the operation was successful
- Throws:
DIException
-
cleanOldALLogs
public static java.lang.Boolean cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, java.util.Date aMinDate, java.util.Date aMaxDate) throws DIException
Cleans AL logs, for a given config ID and Assembly Line name, created after the given Date- Parameters:
aConfigId
- configuration IDaALName
- name of the assembly lineaMinDate
- after this date , the log are deletedaMaxDate
- before this date , the log are deleted- Returns:
- whether the operation was successful
- Throws:
DIException
-
cleanOldALLogs
public static java.lang.Boolean cleanOldALLogs(java.lang.String aConfigId, java.lang.String aALName, int aKeepNum) throws DIException
Cleans AL logs, for a given config ID and Assembly Line name, and leaves only aKeepNum of them- Parameters:
aConfigId
- configuration IDaALName
- name of the assembly lineaKeepNum
- number of logs to keep- Returns:
- whether the operation was successful
- Throws:
DIException
-
cleanALLogs
public static java.lang.String cleanALLogs(java.lang.String aConfigId, java.lang.String aALName, java.lang.String[] logsToBeDeleted) throws DIException
Deletes all the logs which are specified in "logsToBeDeleted
" array.- Parameters:
aConfigId
- identification of the AssemblyLine's Config Instance.aALName
- the name of the AssemblyLine whose logs will be cleaned up.logsToBeDeleted
- name of the log files which are to be deleted.- Returns:
- a
String
that holdsnull
if the log files are deleted successfully; else comma separated names of the log files which are not deleted. - Throws:
DIException
- if an error occurs while deleting log files.
-
getAvailableComponentLogFiles
public static java.lang.String[] getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName, int number)
Retrieves the specified number of available component's log files sorted in ascending order.- Parameters:
aComponentTypeDir
- the component type directoryaConfigId
- the ID of the configuration the Assembly Line belongs toaComponentName
- the component namenumber
- how many of the available log files you need- Returns:
- a String array containing the first number amount of the sorted into ascending order according to the natural ordering of the names of the available log files for the given component
-
getAvailableComponentLogFiles
public static java.lang.String[] getAvailableComponentLogFiles(java.lang.String aComponentTypeDir, java.lang.String aConfigId, java.lang.String aComponentName, java.util.Date dDate)
Retrieves the available component's log files after the specified date sorted in ascending order.- Parameters:
aComponentTypeDir
- the component type directoryaConfigId
- the ID of the configuration the Assembly Line belongs toaComponentName
- the component namedDate
- the earliest Date for the logs needed- Returns:
- a String array containing available log files for the given component which are created after the given Date, sorted into ascending order according to the natural ordering of their names
-
-