Comments (2)
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
from zlogger.
If the issue is still valid for you, the only solution I found it working is to use the following prefix formatting:
logging.AddZLoggerConsole(options =>
{
var prefixFormat = ZString.PrepareUtf8<int, int, int, int, int, int, int, LogLevel>("{0:D4}-{1:D2}-{2:D2} {3:D2}:{4:D2}:{5:D2}.{6:D3} [{7}] ");
options.PrefixFormatter = (writer, info) =>
{
var nowLocalTime = info.Timestamp.DateTime.ToLocalTime();
prefixFormat.FormatTo(ref writer,
nowLocalTime.Year,
nowLocalTime.Month,
nowLocalTime.Day,
nowLocalTime.Hour,
nowLocalTime.Minute,
nowLocalTime.Second,
nowLocalTime.Millisecond,
info.LogLevel);
};
});
This is because Zlogger uses Utf8Formatter.TryFormat
from Microsoft, and this function does not support formatting dates with other formats apart from what is documented at Utf8Formatter.TryFormat. So instead of using DateTime, I deconstruct the current date time in its constituents (year, month, day, hours, etc.) and then use one of the PrepareUtf8 generic overloads to format those integers in date format. D4, D2, D3 formats for integers are passed by the library directly to Utf8Formatter.TryFormat
to format with 4, 2 or 3 leading digits in total including the leading zero if necessary.
The above code produces the following log messages:
2022-12-30 01:09:07.298 [Information] Now listening on: http://localhost:5178
2022-12-30 01:09:07.299 [Information] Application started. Press Ctrl+C to shut down.
2022-12-30 01:09:07.299 [Information] Hosting environment: Development
from zlogger.
Related Issues (20)
- Version mismatch HOT 1
- Using scopes HOT 1
- Unity and structured logging HOT 1
- Worker support? HOT 2
- Binary logging support? HOT 1
- The Unity logger does not allow to provide a context object HOT 4
- Zlogger throws exception when using Unity Editor Playback Options HOT 1
- Ambiguous method call: GetTypeInfo(System.Type) HOT 3
- Unity 2021.2 link issues HOT 4
- AddZLoggerConsole doesn't write Visual Studio's output window on WPF Application HOT 1
- The Unity logger does not allow to provide a context object HOT 3
- Exclude ZLogger functions from stack trace HOT 2
- Unity Editor 2021 IAsyncDisposaple Multiple dll issue HOT 3
- Double clicking the log line in the console doesn't open the file from which the log was initiated HOT 2
- How to use customize structured logging HOT 1
- Load Assembly faild in unity 2021.3.12(MacOs)/15(Win11) HOT 4
- FileLogger not Compatible with WebGL HOT 1
- Typo in the "about" text to the repository HOT 1
- IL2CPP build problem with UnityLoggerFactory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zlogger.