Add rolling log file.

This commit modifies the logging to also log all output to a rolling log
file in the btcd home directory under the logs folder.  It uses a maximum
size of 10MB per log file and a max rotation size of 3.  This means the
log files will not exceed 30 megabytes.
This commit is contained in:
Dave Collins 2013-11-25 12:51:04 -06:00
parent 7e21226ca6
commit 766aae5a72
2 changed files with 5 additions and 2 deletions

View file

@ -39,6 +39,7 @@ var (
knownDbTypes = btcdb.SupportedDBs() knownDbTypes = btcdb.SupportedDBs()
defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key") defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key")
defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert") defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert")
defaultLogFile = filepath.Join(btcdHomeDir, "logs", "btcd.log")
) )
// config defines the configuration options for btcd. // config defines the configuration options for btcd.

4
log.go
View file

@ -131,11 +131,13 @@ func newSeelogLogger() seelog.LoggerInterface {
critmsgcount="500" minlevel="trace"> critmsgcount="500" minlevel="trace">
<outputs formatid="all"> <outputs formatid="all">
<console /> <console />
<rollingfile type="size" filename="%s" maxsize="10485760" maxrolls="3" />
</outputs> </outputs>
<formats> <formats>
<format id="all" format="%Time %Date [%LEV] %Msg%n" /> <format id="all" format="%%Time %%Date [%%LEV] %%Msg%%n" />
</formats> </formats>
</seelog>` </seelog>`
config = fmt.Sprintf(config, defaultLogFile)
logger, err := seelog.LoggerFromConfigAsString(config) logger, err := seelog.LoggerFromConfigAsString(config)
if err != nil { if err != nil {