将结果堆栈跟踪默认写入文件

I use logger in my program defined from pattern as below

var (
    logFile *os.File
    Info    *log.Logger
)

func init() {
    var err error
    logFile, err = os.OpenFile("/my/file/with.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
    if err != nil {
        fmt.Printf("Cannot open log file error:%s. Program was terminated.", err)
        os.Exit(1)
    }
    Info = log.New(logFile,
        "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
 }

Now I would like write all information from stackTrace if these occured for example from panic() to my log file. Now if some gone was wrong all this information are print to console in my IDE, but if porgram works on server, I lose information if occured some null pointer, wrong pass argument to function, that's why I want write this information to log file. It is possible ?

Use syscall.Dup2 to link the opened file to the standard stream

func main() {
   syscall.Dup2(int(logFile.Fd()), 2)
}

or create panic handler

defer func() {
        err := recover()
        if err != nil {
            //...
        }
    }()