[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-4700":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":29,"readmeContent":30,"aiSummary":31,"trendingCount":16,"starSnapshotCount":16,"syncStatus":32,"lastSyncTime":33,"discoverSource":34},4700,"logrus","sirupsen\u002Flogrus","sirupsen","Structured, pluggable logging for Go.","",null,"Go",25733,2280,295,7,0,1,6,26,4,45,"MIT License",false,"master",true,[27,28,5],"go","logging","2026-06-12 02:01:03","# Logrus \u003Cimg src=\"http:\u002F\u002Fi.imgur.com\u002FhTeVwmJ.png\" width=\"40\" height=\"40\" alt=\":walrus:\" class=\"emoji\" title=\":walrus:\"\u002F> [![Build Status](https:\u002F\u002Fgithub.com\u002Fsirupsen\u002Flogrus\u002Fworkflows\u002FCI\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002Fsirupsen\u002Flogrus\u002Factions?query=workflow%3ACI) [![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Fsirupsen\u002Flogrus.svg)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fsirupsen\u002Flogrus)\n\nLogrus is a structured logger for Go (golang), completely API compatible with\nthe standard library logger.\n\n**Logrus is in maintenance mode.** The project focuses on security, bug fixes,\nand performance improvements. New features are not planned, aside from changes\nrequired to provide interoperability with other logging ecosystems (e.g., Go's\n[log\u002Fslog](https:\u002F\u002Fpkg.go.dev\u002Flog\u002Fslog)).\n\nI believe Logrus' biggest contribution is to have played a part in today's\nwidespread use of structured logging in Golang. There doesn't seem to be a\nreason to do a major, breaking iteration into Logrus V2, since the fantastic Go\ncommunity has built those independently. Many fantastic alternatives have sprung\nup. Logrus would look like those, had it been re-designed with what we know\nabout structured logging in Go today. Check out, for example,\n[Zerolog][zerolog], [Zap][zap], and [Apex][apex].\n\n[zerolog]: https:\u002F\u002Fgithub.com\u002Frs\u002Fzerolog\n[zap]: https:\u002F\u002Fgithub.com\u002Fuber-go\u002Fzap\n[apex]: https:\u002F\u002Fgithub.com\u002Fapex\u002Flog\n\nNicely color-coded in development (when a TTY is attached, otherwise just\nplain text):\n\n![Colored](http:\u002F\u002Fi.imgur.com\u002FPY7qMwd.png)\n\nWith `logrus.SetFormatter(&logrus.JSONFormatter{})`, for easy parsing by logstash\nor Splunk:\n\n```text\n{\"animal\":\"walrus\",\"level\":\"info\",\"msg\":\"A group of walrus emerges from the\nocean\",\"size\":10,\"time\":\"2014-03-10 19:57:38.562264131 -0400 EDT\"}\n\n{\"level\":\"warning\",\"msg\":\"The group's number increased tremendously!\",\n\"number\":122,\"omg\":true,\"time\":\"2014-03-10 19:57:38.562471297 -0400 EDT\"}\n\n{\"animal\":\"walrus\",\"level\":\"info\",\"msg\":\"A giant walrus appears!\",\n\"size\":10,\"time\":\"2014-03-10 19:57:38.562500591 -0400 EDT\"}\n\n{\"animal\":\"walrus\",\"level\":\"info\",\"msg\":\"Tremendously sized cow enters the ocean.\",\n\"size\":9,\"time\":\"2014-03-10 19:57:38.562527896 -0400 EDT\"}\n\n{\"level\":\"fatal\",\"msg\":\"The ice breaks!\",\"number\":100,\"omg\":true,\n\"time\":\"2014-03-10 19:57:38.562543128 -0400 EDT\"}\n```\n\nWith the default `logrus.SetFormatter(&logrus.TextFormatter{})` when a TTY is not\nattached, the output is compatible with the\n[logfmt](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fkr\u002Flogfmt) format:\n\n```text\ntime=\"2015-03-26T01:27:38-04:00\" level=debug msg=\"Started observing beach\" animal=walrus number=8\ntime=\"2015-03-26T01:27:38-04:00\" level=info msg=\"A group of walrus emerges from the ocean\" animal=walrus size=10\ntime=\"2015-03-26T01:27:38-04:00\" level=warning msg=\"The group's number increased tremendously!\" number=122 omg=true\ntime=\"2015-03-26T01:27:38-04:00\" level=debug msg=\"Temperature changes\" temperature=-4\ntime=\"2015-03-26T01:27:38-04:00\" level=panic msg=\"It's over 9000!\" animal=orca size=9009\ntime=\"2015-03-26T01:27:38-04:00\" level=fatal msg=\"The ice breaks!\" err=&{0x2082280c0 map[animal:orca size:9009] 2015-03-26 01:27:38.441574009 -0400 EDT panic It's over 9000!} number=100 omg=true\n```\nTo ensure this behaviour even if a TTY is attached, set your formatter as follows:\n\n```go\nlogrus.SetFormatter(&logrus.TextFormatter{\n    DisableColors: true,\n    FullTimestamp: true,\n})\n```\n\n#### Logging Method Name\n\nIf you wish to add the calling method as a field, instruct the logger via:\n\n```go\nlogrus.SetReportCaller(true)\n```\nThis adds the caller as 'method' like so:\n\n```json\n{\"animal\":\"penguin\",\"level\":\"fatal\",\"method\":\"github.com\u002Fsirupsen\u002Farcticcreatures.migrate\",\"msg\":\"a penguin swims by\",\n\"time\":\"2014-03-10 19:57:38.562543129 -0400 EDT\"}\n```\n\n```text\ntime=\"2015-03-26T01:27:38-04:00\" level=fatal method=github.com\u002Fsirupsen\u002Farcticcreatures.migrate msg=\"a penguin swims by\" animal=penguin\n```\nNote that this does add measurable overhead - the cost will depend on the version of Go, but is\nbetween 20 and 40% in recent tests with 1.6 and 1.7.  You can validate this in your\nenvironment via benchmarks:\n\n```bash\ngo test -bench=ReportCaller\n```\n\n#### Case-sensitivity\n\nThe organization's name was [changed to lower-case][1]. If you are getting import\nconflicts due to case sensitivity, please use the lower-case import:\n`github.com\u002Fsirupsen\u002Flogrus`.\n\n[1]: https:\u002F\u002Fgithub.com\u002Fsirupsen\u002Flogrus\u002Fissues\u002F570#issuecomment-313933276\n\n#### Example\n\nThe simplest way to use Logrus is simply the package-level exported logger:\n\n```go\npackage main\n\nimport \"github.com\u002Fsirupsen\u002Flogrus\"\n\nfunc main() {\n  logrus.WithFields(logrus.Fields{\n    \"animal\": \"walrus\",\n  }).Info(\"A walrus appears\")\n}\n```\n\nNote that it's completely api-compatible with the stdlib logger, so you can\nreplace your `log` imports everywhere with `log \"github.com\u002Fsirupsen\u002Flogrus\"`\nand you'll now have the flexibility of Logrus. You can customize it all you\nwant:\n\n```go\npackage main\n\nimport (\n  \"os\"\n\n  log \"github.com\u002Fsirupsen\u002Flogrus\"\n)\n\nfunc init() {\n  \u002F\u002F Log as JSON instead of the default ASCII formatter.\n  log.SetFormatter(&log.JSONFormatter{})\n\n  \u002F\u002F Output to stdout instead of the default stderr\n  \u002F\u002F Can be any io.Writer, see below for File example\n  log.SetOutput(os.Stdout)\n\n  \u002F\u002F Only log the warning severity or above.\n  log.SetLevel(log.WarnLevel)\n}\n\nfunc main() {\n  log.WithFields(log.Fields{\n    \"animal\": \"walrus\",\n    \"size\":   10,\n  }).Info(\"A group of walrus emerges from the ocean\")\n\n  log.WithFields(log.Fields{\n    \"omg\":    true,\n    \"number\": 122,\n  }).Warn(\"The group's number increased tremendously!\")\n\n  log.WithFields(log.Fields{\n    \"omg\":    true,\n    \"number\": 100,\n  }).Fatal(\"The ice breaks!\")\n\n  \u002F\u002F A common pattern is to re-use fields between logging statements by re-using\n  \u002F\u002F the logrus.Entry returned from WithFields()\n  contextLogger := log.WithFields(log.Fields{\n    \"common\": \"this is a common field\",\n    \"other\": \"I also should be logged always\",\n  })\n\n  contextLogger.Info(\"I'll be logged with common and other field\")\n  contextLogger.Info(\"Me too\")\n}\n```\n\nFor more advanced usage such as logging to multiple locations from the same\napplication, you can also create an instance of the `logrus` Logger:\n\n```go\npackage main\n\nimport (\n  \"os\"\n\n  \"github.com\u002Fsirupsen\u002Flogrus\"\n)\n\n\u002F\u002F Create a new instance of the logger. You can have any number of instances.\nvar logger = logrus.New()\n\nfunc main() {\n  \u002F\u002F The API for setting attributes is a little different than the package level\n  \u002F\u002F exported logger. See Godoc. \n  logger.Out = os.Stdout\n\n  \u002F\u002F You could set this to any `io.Writer` such as a file\n  \u002F\u002F file, err := os.OpenFile(\"logrus.log\", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)\n  \u002F\u002F if err == nil {\n  \u002F\u002F  logger.Out = file\n  \u002F\u002F } else {\n  \u002F\u002F  logger.Info(\"Failed to log to file, using default stderr\")\n  \u002F\u002F }\n\n  logger.WithFields(logrus.Fields{\n    \"animal\": \"walrus\",\n    \"size\":   10,\n  }).Info(\"A group of walrus emerges from the ocean\")\n}\n```\n\n#### Fields\n\nLogrus encourages careful, structured logging through logging fields instead of\nlong, unparseable error messages. For example, instead of: `logrus.Fatalf(\"Failed\nto send event %s to topic %s with key %d\")`, you should log the much more\ndiscoverable:\n\n```go\nlogrus.WithFields(logrus.Fields{\n  \"event\": event,\n  \"topic\": topic,\n  \"key\": key,\n}).Fatal(\"Failed to send event\")\n```\n\nWe've found this API forces you to think about logging in a way that produces\nmuch more useful logging messages. We've been in countless situations where just\na single added field to a log statement that was already there would've saved us\nhours. The `WithFields` call is optional.\n\nIn general, with Logrus using any of the `printf`-family functions should be\nseen as a hint you should add a field, however, you can still use the\n`printf`-family functions with Logrus.\n\n#### Default Fields\n\nOften it's helpful to have fields _always_ attached to log statements in an\napplication or parts of one. For example, you may want to always log the\n`request_id` and `user_ip` in the context of a request. Instead of writing\n`logger.WithFields(logrus.Fields{\"request_id\": request_id, \"user_ip\": user_ip})` on\nevery line, you can create a `logrus.Entry` to pass around instead:\n\n```go\nrequestLogger := logger.WithFields(logrus.Fields{\"request_id\": request_id, \"user_ip\": user_ip})\nrequestLogger.Info(\"something happened on that request\") \u002F\u002F will log request_id and user_ip\nrequestLogger.Warn(\"something not great happened\")\n```\n\n#### Hooks\n\nYou can add hooks for logging levels. For example to send errors to an exception\ntracking service on `Error`, `Fatal` and `Panic`, info to StatsD or log to\nmultiple places simultaneously, e.g. syslog.\n\nLogrus comes with [built-in hooks](hooks\u002F). Add those, or your custom hook, in\n`init`:\n\n```go\npackage main\n\nimport (\n  \"log\u002Fsyslog\"\n\n  \"github.com\u002Fsirupsen\u002Flogrus\"\n  airbrake \"gopkg.in\u002Fgemnasium\u002Flogrus-airbrake-hook.v2\"\n  logrus_syslog \"github.com\u002Fsirupsen\u002Flogrus\u002Fhooks\u002Fsyslog\"\n)\n\nfunc init() {\n\n  \u002F\u002F Use the Airbrake hook to report errors that have Error severity or above to\n  \u002F\u002F an exception tracker. You can create custom hooks, see the Hooks section.\n  logrus.AddHook(airbrake.NewHook(123, \"xyz\", \"production\"))\n\n  hook, err := logrus_syslog.NewSyslogHook(\"udp\", \"localhost:514\", syslog.LOG_INFO, \"\")\n  if err != nil {\n    logrus.Error(\"Unable to connect to local syslog daemon\")\n  } else {\n    logrus.AddHook(hook)\n  }\n}\n```\nNote: Syslog hooks also support connecting to local syslog (Ex. \"\u002Fdev\u002Flog\" or \"\u002Fvar\u002Frun\u002Fsyslog\" or \"\u002Fvar\u002Frun\u002Flog\"). For the detail, please check the [syslog hook README](hooks\u002Fsyslog\u002FREADME.md).\n\nA list of currently known service hooks can be found in this wiki [page](https:\u002F\u002Fgithub.com\u002Fsirupsen\u002Flogrus\u002Fwiki\u002FHooks)\n\n\n#### Level logging\n\nLogrus has seven logging levels: Trace, Debug, Info, Warning, Error, Fatal and Panic.\n\n```go\nlogrus.Trace(\"Something very low level.\")\nlogrus.Debug(\"Useful debugging information.\")\nlogrus.Info(\"Something noteworthy happened!\")\nlogrus.Warn(\"You should probably take a look at this.\")\nlogrus.Error(\"Something failed but I'm not quitting.\")\n\u002F\u002F Calls os.Exit(1) after logging\nlogrus.Fatal(\"Bye.\")\n\u002F\u002F Calls panic() after logging\nlogrus.Panic(\"I'm bailing.\")\n```\n\nYou can set the logging level on a `Logger`, then it will only log entries with\nthat severity or anything above it:\n\n```go\n\u002F\u002F Will log anything that is info or above (warn, error, fatal, panic). Default.\nlogrus.SetLevel(logrus.InfoLevel)\n```\n\nIt may be useful to set `logrus.Level = logrus.DebugLevel` in a debug or verbose\nenvironment if your application has that.\n\nNote: If you want different log levels for global (`logrus.SetLevel(...)`) and syslog logging, please check the [syslog hook README](hooks\u002Fsyslog\u002FREADME.md#different-log-levels-for-local-and-remote-logging).\n\n#### Entries\n\nBesides the fields added with `WithField` or `WithFields` some fields are\nautomatically added to all logging events:\n\n1. `time`. The timestamp when the entry was created.\n2. `msg`. The logging message passed to `{Info,Warn,Error,Fatal,Panic}` after\n   the `AddFields` call. E.g. `Failed to send event.`\n3. `level`. The logging level. E.g. `info`.\n\n#### Environments\n\nLogrus has no notion of environment.\n\nIf you wish for hooks and formatters to only be used in specific environments,\nyou should handle that yourself. For example, if your application has a global\nvariable `Environment`, which is a string representation of the environment you\ncould do:\n\n```go\nimport (\n  \"github.com\u002Fsirupsen\u002Flogrus\"\n)\n\nfunc init() {\n  \u002F\u002F do something here to set environment depending on an environment variable\n  \u002F\u002F or command-line flag\n  if Environment == \"production\" {\n    logrus.SetFormatter(&logrus.JSONFormatter{})\n  } else {\n    \u002F\u002F The TextFormatter is default, you don't actually have to do this.\n    logrus.SetFormatter(&logrus.TextFormatter{})\n  }\n}\n```\n\nThis configuration is how `logrus` was intended to be used, but JSON in\nproduction is mostly only useful if you do log aggregation with tools like\nSplunk or Logstash.\n\n#### Formatters\n\nThe built-in logging formatters are:\n\n* `logrus.TextFormatter`. Logs the event in colors if stdout is a tty, otherwise\n  without colors.\n  * *Note:* to force colored output when there is no TTY, set the `ForceColors`\n    field to `true`.  To force no colored output even if there is a TTY  set the\n    `DisableColors` field to `true`. For Windows, see\n    [github.com\u002Fmattn\u002Fgo-colorable](https:\u002F\u002Fgithub.com\u002Fmattn\u002Fgo-colorable).\n  * When colors are enabled, levels are truncated to 4 characters by default. To disable\n    truncation set the `DisableLevelTruncation` field to `true`.\n  * When outputting to a TTY, it's often helpful to visually scan down a column where all the levels are the same width. Setting the `PadLevelText` field to `true` enables this behavior, by adding padding to the level text.\n  * All options are listed in the [generated docs](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fsirupsen\u002Flogrus#TextFormatter).\n* `logrus.JSONFormatter`. Logs fields as JSON.\n  * All options are listed in the [generated docs](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Fsirupsen\u002Flogrus#JSONFormatter).\n\nThird-party logging formatters:\n\n* [`FluentdFormatter`](https:\u002F\u002Fgithub.com\u002Fjoonix\u002Flog). Formats entries that can be parsed by Kubernetes and Google Container Engine.\n* [`GELF`](https:\u002F\u002Fgithub.com\u002Ffabienm\u002Fgo-logrus-formatters). Formats entries so they comply to Graylog's [GELF 1.1 specification](http:\u002F\u002Fdocs.graylog.org\u002Fen\u002F2.4\u002Fpages\u002Fgelf.html).\n* [`logstash`](https:\u002F\u002Fgithub.com\u002Fbshuster-repo\u002Flogrus-logstash-hook). Logs fields as [Logstash](http:\u002F\u002Flogstash.net) Events.\n* [`prefixed`](https:\u002F\u002Fgithub.com\u002Fx-cray\u002Flogrus-prefixed-formatter). Displays log entry source along with alternative layout.\n* [`zalgo`](https:\u002F\u002Fgithub.com\u002Faybabtme\u002Flogzalgo). Invoking the Power of Zalgo.\n* [`nested-logrus-formatter`](https:\u002F\u002Fgithub.com\u002Fantonfisher\u002Fnested-logrus-formatter). Converts logrus fields to a nested structure.\n* [`powerful-logrus-formatter`](https:\u002F\u002Fgithub.com\u002Fzput\u002FzxcTool). get fileName, log's line number and the latest function's name when print log; Save log to files.\n* [`caption-json-formatter`](https:\u002F\u002Fgithub.com\u002Fnolleh\u002Fcaption_json_formatter). logrus's message json formatter with human-readable caption added.\n* [`easy-logrus-formatter`](https:\u002F\u002Fgithub.com\u002FWeiZhixiong\u002Feasy-logrus-formatter). Provide a user-friendly formatter for logrus.\n* [`redactrus`](https:\u002F\u002Fgithub.com\u002Fibreakthecloud\u002Fredactrus). Redacts sensitive information like password, apikeys, email, etc. from logs.\n\nYou can define your formatter by implementing the `Formatter` interface,\nrequiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a\n`Fields` type (`map[string]any`) with all your fields as well as the\ndefault ones (see Entries section above):\n\n```go\ntype MyJSONFormatter struct{}\n\nlogrus.SetFormatter(new(MyJSONFormatter))\n\nfunc (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {\n  \u002F\u002F Note this doesn't include Time, Level and Message which are available on\n  \u002F\u002F the Entry. Consult `godoc` on information about those fields or read the\n  \u002F\u002F source of the official loggers.\n  serialized, err := json.Marshal(entry.Data)\n    if err != nil {\n      return nil, fmt.Errorf(\"Failed to marshal fields to JSON, %w\", err)\n    }\n  return append(serialized, '\\n'), nil\n}\n```\n\n#### Logger as an `io.Writer`\n\nLogrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.\n\n```go\nw := logger.Writer()\ndefer w.Close()\n\nsrv := http.Server{\n    \u002F\u002F create a stdlib log.Logger that writes to\n    \u002F\u002F logrus.Logger.\n    ErrorLog: log.New(w, \"\", 0),\n}\n```\n\nEach line written to that writer will be printed the usual way, using formatters\nand hooks. The level for those entries is `info`.\n\nThis means that we can override the standard library logger easily:\n\n```go\nlogger := logrus.New()\nlogger.Formatter = &logrus.JSONFormatter{}\n\n\u002F\u002F Use logrus for standard log output\n\u002F\u002F Note that `log` here references stdlib's log\n\u002F\u002F Not logrus imported under the name `log`.\nlog.SetOutput(logger.Writer())\n```\n\n#### Rotation\n\nLog rotation is not provided with Logrus. Log rotation should be done by an\nexternal program (like `logrotate(8)`) that can compress and delete old log\nentries. It should not be a feature of the application-level logger.\n\n#### Tools\n\n| Tool | Description |\n| ---- | ----------- |\n|[Logrus Mate](https:\u002F\u002Fgithub.com\u002Fgogap\u002Flogrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will be generated with different configs in different environments.|\n|[Logrus Viper Helper](https:\u002F\u002Fgithub.com\u002Fheirko\u002Fgo-contrib\u002Ftree\u002Fmaster\u002FlogrusHelper)|An Helper around Logrus to wrap with spf13\u002FViper to load configuration with fangs! And to simplify Logrus configuration use some behavior of [Logrus Mate](https:\u002F\u002Fgithub.com\u002Fgogap\u002Flogrus_mate). [sample](https:\u002F\u002Fgithub.com\u002Fheirko\u002Firis-contrib\u002Fblob\u002Fmaster\u002Fmiddleware\u002Flogrus-logger\u002Fexample) |\n\n#### Testing\n\nLogrus has a built-in facility for asserting the presence of log messages. This is implemented through the `test` hook and provides:\n\n* decorators for existing logger (`test.NewLocal` and `test.NewGlobal`) which basically just adds the `test` hook\n* a test logger (`test.NewNullLogger`) that just records log messages (and does not output any):\n\n```go\nimport(\n  \"testing\"\n\n  \"github.com\u002Fsirupsen\u002Flogrus\"\n  \"github.com\u002Fsirupsen\u002Flogrus\u002Fhooks\u002Ftest\"\n  \"github.com\u002Fstretchr\u002Ftestify\u002Fassert\"\n)\n\nfunc TestSomething(t*testing.T){\n  logger, hook := test.NewNullLogger()\n  logger.Error(\"Helloerror\")\n\n  assert.Equal(t, 1, len(hook.Entries))\n  assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level)\n  assert.Equal(t, \"Helloerror\", hook.LastEntry().Message)\n\n  hook.Reset()\n  assert.Nil(t, hook.LastEntry())\n}\n```\n\n#### Fatal handlers\n\nLogrus can register one or more functions that will be called when any `fatal`\nlevel message is logged. The registered handlers will be executed before\nlogrus performs an `os.Exit(1)`. This behavior may be helpful if callers need\nto gracefully shut down. Unlike a `panic(\"Something went wrong...\")` call which can be intercepted with a deferred `recover` a call to `os.Exit(1)` can not be intercepted.\n\n```go\n\u002F\u002F ...\nhandler := func() {\n  \u002F\u002F gracefully shut down something...\n}\nlogrus.RegisterExitHandler(handler)\n\u002F\u002F ...\n```\n\n#### Thread safety\n\nBy default, Logger is protected by a mutex for concurrent writes. The mutex is held when calling hooks and writing logs.\nIf you are sure such locking is not needed, you can call logger.SetNoLock() to disable the locking.\n\nSituations when locking is not needed include:\n\n* You have no hooks registered, or hooks calling is already thread-safe.\n\n* Writing to logger.Out is already thread-safe, for example:\n\n  1) logger.Out is protected by locks.\n\n  2) logger.Out is an os.File handler opened with `O_APPEND` flag, and every write is smaller than 4k. (This allows multi-thread\u002Fmulti-process writing)\n\n     (Refer to http:\u002F\u002Fwww.notthewizard.com\u002F2014\u002F06\u002F17\u002Fare-files-appends-really-atomic\u002F)\n","Logrus 是一个为 Go 语言设计的结构化日志库，与 Go 标准库的日志接口完全兼容。它支持多种格式化输出，包括 JSON 和 logfmt，在开发环境中能够根据终端类型自动选择是否使用颜色编码以提高可读性。此外，Logrus 具有高度的可扩展性，允许用户通过插件机制自定义日志处理逻辑。虽然该项目目前处于维护模式，主要关注安全修复和性能优化，但其对于推动 Go 项目中结构化日志记录实践的应用贡献巨大。Logrus 适用于需要高效且灵活的日志解决方案的各种 Go 应用场景，特别是那些对日志内容进行进一步分析或存储有需求的情况。",2,"2026-06-11 03:00:12","top_language"]