官方文件概述了如何使用該字段: // ErrorLog specifies an optional logger for errors accepting // connections, unexpected behavior from handlers, and // underlying FileSystem errors. // If nil, logging is done via the log package's standard logger. ErrorLog *log.Logger // Go 1.3 實際上,該字段是通過*http.Server的logf方法訪問的。您可以檢查調(diào)用該方法的位置。簡而言之(并非詳盡無遺): 在為HTTP請求服務的panic上(conn的serve(ctx context.Context)) 關于TLS握手錯誤 服務器的Serve(l net.Listener) error錯誤 在將non-empty數(shù)據(jù)寫入響應時,如果連接被劫持 如果Content-Length無效 如果對同一個響應多次調(diào)用WriteHeader(code int) 如果Content-Length和非identityTransfer-Encoding頭一起使用