14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Golang と Syslog

Posted at

func NewLogger(p Priority, logFlag int) (*log.Logger, error)

func New(priority Priority, tag string) (w *Writer, err error)

を使う

#sample

package main

import (
  "runtime"

  "log"
  "log/syslog"
)

func main() {

  logger, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_USER, "my-daemon")
  if err != nil {
    panic(err)
  }
  log.SetOutput(logger)

  log.Println("num gogoutine:", runtime.NumGoroutine())
}

marvericks で /var/log/system.log に出力されているのを確認。

#チラ裏

func SetOutput(w io.Writer)

io.Writer 装備すればなんでもいいのか! 納得。

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?