You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-26Lines changed: 27 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,29 +57,29 @@ import Logging
57
57
importLoggingELK
58
58
```
59
59
60
-
Create the `LogstashLogHandler` with the appropriate configuration and register the to be used logging backend once (!) during the lifetime of the application:
60
+
Setup the `LogstashLogHandler` with the appropriate configuration and register the to be used logging backend once (!) during the lifetime of the application:
@@ -93,19 +93,20 @@ The `LogstashLogHandler` can also be configured beyond the standard configuratio
93
93
Why at least twice as large? The process of allocating temporary buffers could possibly be repeated, if the log storage runs full during uploading of "old" log data. A possible scenario is an environment, where the network conncection to Logstash is really slow and therefore the uploading takes long. This process could repeat itself over and over again until the `maximumTotalLogStorageSize` is reached. Then, a new logging call blocks until enought memory space is available again, achieved through a partial completed uploading of log data, resulting in freed temporary buffers. In practice, approaching the `maximumTotalLogStorageSize` should basically never happen, except in very resource restricted environments.
94
94
95
95
```swift
96
-
LoggingSystem.bootstrap { label in
97
-
LogstashLogHandler(
98
-
label: "logstash",
99
-
hostname: "0.0.0.0",
100
-
port: 31311,
101
-
useHTTPS: false,
102
-
eventLoopGroup: eventLoopGroup,
103
-
backgroundActivityLogger: logger,
104
-
uploadInterval: TimeAmount.seconds(3),
105
-
logStorageSize: 524_288, // 512kB
106
-
maximumTotalLogStorageSize: 2_097_152// 2MB
107
-
)
108
-
}
96
+
// Setup of LogstashLogHandler
97
+
LogstashLogHandler.setup(
98
+
hostname: "0.0.0.0",
99
+
port: 31311,
100
+
useHTTPS: false,
101
+
eventLoopGroup: eventLoopGroup,
102
+
backgroundActivityLogger: logger,
103
+
uploadInterval: TimeAmount.seconds(5),
104
+
logStorageSize: 500_000,
105
+
maximumTotalLogStorageSize: 4_000_000
106
+
)
107
+
108
+
// Register LogstashLogHandler in the LoggingSystem
109
+
LoggingSystem.bootstrap(LogstashLogHandler.init)
109
110
```
110
111
111
112
Now that the setup of the `LogstashLogHandler` is completed, you can use `SwiftLog` as usual (also with metadata etc.).
0 commit comments