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
If you are looking for a version compatible with Scala 2.10, check out Scala Logging 2.x.
@@ -94,6 +94,28 @@ class MyClass extends LazyLogging {
94
94
- SLF4J loggers and our Logger now survive serialization. By survive serialization, we mean that the
95
95
deserialized logger instances are fully functional.
96
96
97
+
## String Interpolation
98
+
It is idiomatic to use Scala's string interpolation `logger.error(s"log $value")` instead of SLF4J string interpolation `logger.error("log {}", value)`.
99
+
However there are some tools (such as [Sentry](https://sentry.io)) that use the log message format as grouping key. Therefore they do not work well with
100
+
Scala's string interpolation.
101
+
102
+
Scala Logging replaces simple string interpolations with their SLF4J counterparts like this:
This has no effect on behavior and performace should be comparable (depends on the underlying logging library).
113
+
114
+
### Limitations
115
+
- Works only when string interpolation is directly used inside the logging statement. That is when the log message is static (available at compile time).
116
+
- Works only for the `logger.<level>(message)` and `logger.<level>(marker, message)` logging methods. It does not work if you want to log an exception and
117
+
use string interpolation too (this is a limitation of the SLF4J API).
118
+
97
119
## Line numbers in log message?
98
120
99
121
Using the [sourcecode](https://github.com/lihaoyi/sourcecode#logging) library, it's possible to add line number
0 commit comments