natefinch / lumberjack

lumberjack is a log rolling package for Go
MIT License
4.8k stars 591 forks source link

Log file rotation is failing with exception #21

Closed ShanthkumarS079 closed 8 years ago

ShanthkumarS079 commented 8 years ago

We are using lumberjack Version 2 Log file rotation is failing with exception slice out of bound exception panic: runtime error: slice bounds out of range

Stack trace of exception.

goroutine 1 [running]: github.com/natefinch/lumberjack.(_Logger).cleanup(0xc0820122a0, 0x0, 0x0) D:/ADMWorkspace/Cloud Workspace/SDL_operations/src/Godeps/_workspace/src/github.com/natefinch/lumberjack/lumberjack.go:269 +0x692 github.com/natefinch/lumberjack.(_Logger).rotate(0xc0820122a0, 0x0, 0x0) D:/ADMWorkspace/Cloud Workspace/SDL_operations/src/Godeps/_workspace/src/github.com/natefinch/lumberjack/lumberjack.go:179 +0xbc github.com/natefinch/lumberjack.(_Logger).Write(0xc0820122a0, 0xc082036d00, 0x7a, 0xca, 0x0, 0x0, 0x0) D:/ADMWorkspace/Cloud Workspace/SDL_operations/src/Godeps/_workspace/src/github.com/natefinch/lumberjack/lumberjack.go:131 +0x405 bytes.(_Buffer).WriteTo(0xc082030460, 0xc94520, 0xc0820122a0, 0x0, 0x0, 0x0) c:/go/src/bytes/buffer.go:206 +0xcf io.copyBuffer(0xc94520, 0xc0820122a0, 0xc945a8, 0xc082030460, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)

Please help us to resolve this issue

natefinch commented 8 years ago

It looks like you're not actually using lumberjack v2. The import path should be gopkg.in/natefinch/lumberjack.v2 (and the code should be in the corresponding path in your Godeps workspace heirarchy). The line numbers reported by the panic reflect this as well, as they refer to the 1.0 codebase.

ShanthkumarS079 commented 8 years ago

Using lumberjackV2 it's working fine. Is there any way to customize the logfile names during log file rotation

natefinch commented 8 years ago

Not now, no. There's just a timestamp appended to the name (before the extension, if any). It's important that the log files have unique names, and it's just easiest to use a timestamp, so you never have to worry about collisions with older files.

ShanthkumarS079 commented 8 years ago

Is there a way to zip the old log files?

natefinch commented 8 years ago

Not yet, no... though it's something that has been brought up repeatedly. It's definitely a good idea.