top
(README.md)
[![Build Status](https://travis-ci.org/RackSec/srslog.svg?branch=master)](https://travis-ci.org/RackSec/srslog)

# srslog

Go has a `syslog` package in the standard library, but it has the following
shortcomings:

1. It doesn't have TLS support
2. [According to bradfitz on the Go team, it is no longer being maintained.](https://github.com/golang/go/issues/13449#issuecomment-161204716)

I agree that it doesn't need to be in the standard library. So, I've
followed Brad's suggestion and have made a separate project to handle syslog.

This code was taken directly from the Go project as a base to start from.

However, this _does_ have TLS support.

# Usage

Basic usage retains the same interface as the original `syslog` package. We
only added to the interface where required to support new functionality.

Switch from the standard library:

```
import(
    //"log/syslog"
    syslog "github.com/RackSec/srslog"
)
```

You can still use it for local syslog:

```
w, err := syslog.Dial("", "", syslog.LOG_ERR, "testtag")
```

Or to unencrypted UDP:

```
w, err := syslog.Dial("udp", "192.168.0.50:514", syslog.LOG_ERR, "testtag")
```

Or to unencrypted TCP:

```
w, err := syslog.Dial("tcp", "192.168.0.51:514", syslog.LOG_ERR, "testtag")
```

But now you can also send messages via TLS-encrypted TCP:

```
w, err := syslog.DialWithTLSCertPath("tcp+tls", "192.168.0.52:514", syslog.LOG_ERR, "testtag", "/path/to/servercert.pem")
```

And if you need more control over your TLS configuration :

```
pool := x509.NewCertPool()
serverCert, err := ioutil.ReadFile("/path/to/servercert.pem")
if err != nil {
    return nil, err
}
pool.AppendCertsFromPEM(serverCert)
config := tls.Config{
    RootCAs: pool,
}

w, err := DialWithTLSConfig(network, raddr, priority, tag, &config)
```

(Note that in both TLS cases, this uses a self-signed certificate, where the
remote syslog server has the keypair and the client has only the public key.)

And then to write log messages, continue like so:

```
if err != nil {
    log.Fatal("failed to connect to syslog:", err)
}
defer w.Close()

w.Alert("this is an alert")
w.Crit("this is critical")
w.Err("this is an error")
w.Warning("this is a warning")
w.Notice("this is a notice")
w.Info("this is info")
w.Debug("this is debug")
w.Write([]byte("these are some bytes"))
```

# Generating TLS Certificates

We've provided a script that you can use to generate a self-signed keypair:

```
pip install cryptography
python script/gen-certs.py
```

That outputs the public key and private key to standard out. Put those into
`.pem` files. (And don't put them into any source control. The certificate in
the `test` directory is used by the unit tests, and please do not actually use
it anywhere else.)

# Running Tests

Run the tests as usual:

```
go test
```

But we've also provided a test coverage script that will show you which
lines of code are not covered:

```
script/coverage --html
```

That will open a new browser tab showing coverage information.

# License

This project uses the New BSD License, the same as the Go project itself.

# Code of Conduct

Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.

Imported by 225 package(s) ΒΆ

  1. github.com/0xAX/docker/daemon/logger/syslog
  2. github.com/45cali/docker/daemon/logger/syslog
  3. github.com/AkihiroSuda/docker/daemon/logger/syslog
  4. github.com/Aorjoa/docker-arm/daemon/logger/syslog
  5. github.com/BenHall/docker/daemon/logger/syslog
  6. github.com/BrianBland/docker/daemon/logger/syslog
  7. github.com/BrickXu/docker/daemon/logger/syslog
  8. github.com/Collinux/docker/daemon/logger/syslog
  9. github.com/DieterReuter/docker/daemon/logger/syslog
  10. github.com/EderRoger/docker/daemon/logger/syslog
  11. github.com/FillZpp/docker/daemon/logger/syslog
  12. github.com/Gnouc/docker/daemon/logger/syslog
  13. github.com/HewlettPackard/docker/daemon/logger/syslog
  14. github.com/HideoYamauchi/docker/daemon/logger/syslog
  15. github.com/HuKeping/docker/daemon/logger/syslog
  16. github.com/IanLewis/docker/daemon/logger/syslog
  17. github.com/JensRantil/docker/daemon/logger/syslog
  18. github.com/JesusTinoco/docker/daemon/logger/syslog
  19. github.com/JetMuffin/docker/daemon/logger/syslog
  20. github.com/Jimmy-Xu/hypercli/daemon/logger/syslog
  21. github.com/Ketouem/docker/daemon/logger/syslog
  22. github.com/Kuwagata/docker/daemon/logger/syslog
  23. github.com/LarsFronius/docker/daemon/logger/syslog
  24. github.com/Morsicus/docker/daemon/logger/syslog
  25. github.com/Munsy/docker/daemon/logger/syslog
  26. github.com/Oscarzhao/docker/daemon/logger/syslog
  27. github.com/PI-Victor/docker/daemon/logger/syslog
  28. github.com/Random-Liu/docker/daemon/logger/syslog
  29. github.com/RobinGeuze/docker/daemon/logger/syslog
  30. github.com/SUSE/docker/daemon/logger/syslog
  31. github.com/SvenDowideit/docker/daemon/logger/syslog
  32. github.com/Test-Betta-Inc/docker/daemon/logger/syslog
  33. github.com/Test-Betta-Inc/psychic-barnacle/daemon/logger/syslog
  34. github.com/Treeptik/docker/daemon/logger/syslog
  35. github.com/VonC/docker/daemon/logger/syslog
  36. github.com/WIZARD-CXY/docker/daemon/logger/syslog
  37. github.com/WeiZhang555/docker/daemon/logger/syslog
  38. github.com/ZachBergh/docker/daemon/logger/syslog
  39. github.com/abhinavdahiya/docker/daemon/logger/syslog
  40. github.com/abronan/docker/daemon/logger/syslog
  41. github.com/absourdnoise/docker/daemon/logger/syslog
  42. github.com/achanda/docker/daemon/logger/syslog
  43. github.com/aclisp/docker/daemon/logger/syslog
  44. github.com/adnaan/docker/daemon/logger/syslog
  45. github.com/aidanhs/docker/daemon/logger/syslog
  46. github.com/ailispaw/docker/daemon/logger/syslog
  47. github.com/aksentyev/docker/daemon/logger/syslog
  48. github.com/alertisme/docker/daemon/logger/syslog
  49. github.com/alexblanquart/docker/daemon/logger/syslog
  50. github.com/allencloud/docker/daemon/logger/syslog
  51. github.com/andrejbaran/docker/daemon/logger/syslog
  52. github.com/andrewzeneski/docker/daemon/logger/syslog
  53. github.com/apeace/docker/daemon/logger/syslog
  54. github.com/arvinkulagin/docker/daemon/logger/syslog
  55. github.com/asbjornenge/docker/daemon/logger/syslog
  56. github.com/awakenetworks/docker/daemon/logger/syslog
  57. github.com/bamarni/docker/daemon/logger/syslog
  58. github.com/benizi/docker/daemon/logger/syslog
  59. github.com/bergwolf/hypercli/daemon/logger/syslog
  60. github.com/bluebreezecf/docker/daemon/logger/syslog
  61. github.com/blufor/metcap
  62. github.com/boynux/docker/daemon/logger/syslog
  63. github.com/brahmaroutu/docker/daemon/logger/syslog
  64. github.com/carbonblack/cb-event-forwarder
  65. github.com/carbonblack/docker/daemon/logger/syslog
  66. github.com/carmark/hypercli/daemon/logger/syslog
  67. github.com/cgt212/docker/daemon/logger/syslog
  68. github.com/chosenken/docker/daemon/logger/syslog
  69. github.com/chrisbbe/docker/daemon/logger/syslog
  70. github.com/christopherobin/docker/daemon/logger/syslog
  71. github.com/cirias/docker/daemon/logger/syslog
  72. github.com/citysir/docker/daemon/logger/syslog
  73. github.com/cjellick/docker/daemon/logger/syslog
  74. github.com/ckeyer/docker/daemon/logger/syslog
  75. github.com/clinta/docker/daemon/logger/syslog
  76. github.com/cmehay/docker-1/daemon/logger/syslog
  77. github.com/cnaize/docker/daemon/logger/syslog
  78. github.com/codematix/docker/daemon/logger/syslog
  79. github.com/contiv/docker/daemon/logger/syslog
  80. github.com/convox/syslog
  81. github.com/cpuguy83/docker/daemon/logger/syslog
  82. github.com/cr7pt0gr4ph7/docker/daemon/logger/syslog
  83. github.com/crosbymichael/docker/daemon/logger/syslog
  84. github.com/csfrancis/docker/daemon/logger/syslog
  85. github.com/cyphar/docker/daemon/logger/syslog
  86. github.com/darrellpratt/docker/daemon/logger/syslog
  87. github.com/daxzhuo/docker/daemon/logger/syslog
  88. github.com/denverdino/docker/daemon/logger/syslog
  89. github.com/dinever/docker/daemon/logger/syslog
  90. github.com/dlespiau/docker/daemon/logger/syslog
  91. github.com/dnephin/docker/daemon/logger/syslog
  92. github.com/docker/docker/daemon/logger/syslog
  93. github.com/dolftax/docker/daemon/logger/syslog
  94. github.com/donnie4w/docker/daemon/logger/syslog
  95. github.com/dpiddy/docker/daemon/logger/syslog
  96. github.com/dqminh/docker/daemon/logger/syslog
  97. github.com/duglin/docker/daemon/logger/syslog
  98. github.com/ehazlett/docker/daemon/logger/syslog
  99. github.com/elliot/docker/daemon/logger/syslog
  100. github.com/endocode/docker/daemon/logger/syslog
  101. github.com/erikstmartin/docker/daemon/logger/syslog
  102. github.com/erizocosmico/docker/daemon/logger/syslog
  103. github.com/estesp/docker/daemon/logger/syslog
  104. github.com/faizalpribadi/docker/daemon/logger/syslog
  105. github.com/fanux/docker/daemon/logger/syslog
  106. github.com/flavio/docker/daemon/logger/syslog
  107. github.com/fntlnz/docker/daemon/logger/syslog
  108. github.com/frapposelli/docker/daemon/logger/syslog
  109. github.com/gambol99/docker/daemon/logger/syslog
  110. github.com/gao-feng/docker/daemon/logger/syslog
  111. github.com/gaocegege/docker/daemon/logger/syslog
  112. github.com/gdm85/docker/daemon/logger/syslog
  113. github.com/go-experimental/log/handlers/syslog
  114. github.com/go-playground/log/handlers/syslog
  115. github.com/gondor/docker/daemon/logger/syslog
  116. github.com/grutz/logrus_srslog
  117. github.com/gysan/docker/daemon/logger/syslog
  118. github.com/hallyn/docker/daemon/logger/syslog
  119. github.com/hamo/docker/daemon/logger/syslog
  120. github.com/hare85/docker/daemon/logger/syslog
  121. github.com/henvic/docker/daemon/logger/syslog
  122. github.com/hfm/docker/daemon/logger/syslog
  123. github.com/hillzhang/docker/daemon/logger/syslog
  124. github.com/hustcat/docker/daemon/logger/syslog
  125. github.com/hyperhq/hypercli/daemon/logger/syslog
  126. github.com/icecrime/docker/daemon/logger/syslog
  127. github.com/ilgooz/docker/daemon/logger/syslog
  128. github.com/ilkka/docker/daemon/logger/syslog
  129. github.com/imeoer/hypercli/daemon/logger/syslog
  130. github.com/inercia/docker/daemon/logger/syslog
  131. github.com/intoxicated/docker/daemon/logger/syslog
  132. github.com/jainvipin/docker/daemon/logger/syslog
  133. github.com/jawher/docker/daemon/logger/syslog
  134. github.com/jc-m/docker/daemon/logger/syslog
  135. github.com/jeromedoucet/docker/daemon/logger/syslog
  136. github.com/jessfraz/docker/daemon/logger/syslog
  137. github.com/jfrazelle/docker/daemon/logger/syslog
  138. github.com/johnt337/docker/daemon/logger/syslog
  139. github.com/jsoriano/docker/daemon/logger/syslog
  140. github.com/jwhonce/docker/daemon/logger/syslog
  141. github.com/kakilangit/docker-engine/daemon/logger/syslog
  142. github.com/kasisnu/docker/daemon/logger/syslog
  143. github.com/kencochrane/docker/daemon/logger/syslog
  144. github.com/kevinjqiu/docker/daemon/logger/syslog
  145. github.com/kim0/docker/daemon/logger/syslog
  146. github.com/kobeld/docker/daemon/logger/syslog
  147. github.com/kouhin/docker/daemon/logger/syslog
  148. github.com/lai-nam/docker/daemon/logger/syslog
  149. github.com/lchi/docker/daemon/logger/syslog
  150. github.com/lxfontes/docker/daemon/logger/syslog
  151. github.com/machinaut/docker/daemon/logger/syslog
  152. github.com/maliceio/engine/daemon/logger/syslog
  153. github.com/mattyr/docker/daemon/logger/syslog
  154. github.com/mesos-utility/docker/daemon/logger/syslog
  155. github.com/mgazz/docker/daemon/logger/syslog
  156. github.com/mgilbir/docker/daemon/logger/syslog
  157. github.com/mgoelzer/docker/daemon/logger/syslog
  158. github.com/michael-k/docker/daemon/logger/syslog
  159. github.com/mingqing/docker/daemon/logger/syslog
  160. github.com/mssola/docker/daemon/logger/syslog
  161. github.com/mtrmac/docker/daemon/logger/syslog
  162. github.com/munsy/docker/daemon/logger/syslog
  163. github.com/mybruce/docker/daemon/logger/syslog
  164. github.com/nalind/docker/daemon/logger/syslog
  165. github.com/nerdalert/docker/daemon/logger/syslog
  166. github.com/nguyentm83/docker/daemon/logger/syslog
  167. github.com/nictuku/docker/daemon/logger/syslog
  168. github.com/noxiouz/docker/daemon/logger/syslog
  169. github.com/ojongerius/docker/daemon/logger/syslog
  170. github.com/pandrew/docker/daemon/logger/syslog
  171. github.com/pcarrier/docker/daemon/logger/syslog
  172. github.com/pdxjohnny/docker/daemon/logger/syslog
  173. github.com/philips/docker/daemon/logger/syslog
  174. github.com/projectatomic/docker/daemon/logger/syslog
  175. github.com/public0821/docker/daemon/logger/syslog
  176. github.com/qianxiangshan/docker/daemon/logger/syslog
  177. github.com/random-liu/docker/daemon/logger/syslog
  178. github.com/reds/docker/daemon/logger/syslog
  179. github.com/rhatdan/docker/daemon/logger/syslog
  180. github.com/rhatdan/moby/daemon/logger/syslog
  181. github.com/rhatdan/moby1/daemon/logger/syslog
  182. github.com/rtuin/docker/daemon/logger/syslog
  183. github.com/rxwen/docker/daemon/logger/syslog
  184. github.com/s-matyukevich/docker/daemon/logger/syslog
  185. github.com/sallyom/docker/daemon/logger/syslog
  186. github.com/sandlbn/docker/daemon/logger/syslog
  187. github.com/satanson/docker/daemon/logger/syslog
  188. github.com/scollier/docker/daemon/logger/syslog
  189. github.com/sdurrheimer/docker/daemon/logger/syslog
  190. github.com/shenoyvvarun/docker/daemon/logger/syslog
  191. github.com/shin-/docker/daemon/logger/syslog
  192. github.com/shishir-a412ed/docker/daemon/logger/syslog
  193. github.com/shubhodeep9/docker/daemon/logger/syslog
  194. github.com/skatsuta/docker/daemon/logger/syslog
  195. github.com/slimsag/docker/daemon/logger/syslog
  196. github.com/slimsag/docker10/daemon/logger/syslog
  197. github.com/smo921/docker-fork/daemon/logger/syslog
  198. github.com/soulshake/docker/daemon/logger/syslog
  199. github.com/stapelberg/docker/daemon/logger/syslog
  200. github.com/stevvooe/docker/daemon/logger/syslog
  201. github.com/superryanguo/docker/daemon/logger/syslog
  202. github.com/swasd/baleno/daemon/logger/syslog
  203. github.com/takecy/docker/daemon/logger/syslog
  204. github.com/tanji/docker/daemon/logger/syslog
  205. github.com/tetrafolium/docker/daemon/logger/syslog
  206. github.com/tiborvass/docker/daemon/logger/syslog
  207. github.com/tomkadwill/docker/daemon/logger/syslog
  208. github.com/trayo/docker/daemon/logger/syslog
  209. github.com/umerazad/docker/daemon/logger/syslog
  210. github.com/unclejack/docker/daemon/logger/syslog
  211. github.com/unclejack/moby/daemon/logger/syslog
  212. github.com/vieux/docker/daemon/logger/syslog
  213. github.com/wallyqs/docker/daemon/logger/syslog
  214. github.com/weaveworks/docker/daemon/logger/syslog
  215. github.com/willmtemple/docker/daemon/logger/syslog
  216. github.com/wolf/docker/daemon/logger/syslog
  217. github.com/wzhliang/docker/daemon/logger/syslog
  218. github.com/xianlubird/docker/daemon/logger/syslog
  219. github.com/xtaci/docker/daemon/logger/syslog
  220. github.com/yosifkit/docker/daemon/logger/syslog
  221. github.com/ywk253100/docker/daemon/logger/syslog
  222. gopkg.in/docker/docker.v1/daemon/logger/syslog
  223. gopkg.in/dotcloud/docker.v1/daemon/logger/syslog
  224. gopkg.in/hashicorp/nomad.v0/client/driver/executor
  225. gopkg.in/hashicorp/nomad.v0/client/driver/logging