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()
defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key")
defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert")
defaultLogFile = filepath.Join(btcdHomeDir, "logs", "btcd.log")
)
// config defines the configuration options for btcd.

6
log.go
View file

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