Comments (4)
Hi @sallyyu0 👋
There are a few things going on here.
All logs still go to console. Is not it supposed to be different?
Your logs should end up being written to stdout
and appear in your terminal. Is the problem that you're running cargo test
and your logs are suddenly showing up there instead of being captured like println!
is?
Note that I did get following error and not sure why So I made change as instructed by adding "self", it passed.
This one is Rust itself being picky. Usually you only put extern crate ..;
statements in your root lib.rs
or main.rs
. When you do that you can just use ..;
in other modules like logger.rs
.
INFO 2018-11-02T19:17:37Z: myapp::utils::logger: builder=Logger { filter: Filter { filter: None, directives: [] }, writer: Logger { target: Stdout, write_style: Auto } }
This one is our bad. That Logger { .. }
is actually lying about its fields. After calling builder.init()
we replace those fields with default values so it doesn't tell you what the Builder
looked like before. I opened #110 to fix that up.
from env_logger.
I was hoping a way NOT to print the logs to the terminal instead to a file, or a server
Ah right. Yeh, env_logger
only supports logging to a terminal. If you'd like to send your logs elsewhere you could take a look at log4rs
which has rolling file support.
access to extern crates through prelude is experimental
I think this is another picky modules error. You shouldn't need the extern crate env_logger;
statement in your logger.rs
file, but you might instead need a use env_logger;
statement. These are nasty little papercuts that are cleaned up in a new edition of the language. If you transition your project to the current 2018 edition then you shouldn't need any extern crate env_logger
or use env_logger;
statements at all.
from env_logger.
Hi KodrAus,
Thanks for the response. I was hoping a way NOT to print the logs to the terminal instead to a file, or a server even though I see there are only two options, stderr and stdout.
About the build error: When I don't have "extern crate env_logger;", I get this error instead.
error[E0658]: access to extern crates through prelude is experimental (see issue #44660)
from env_logger.
It looks we've worked through your original concerns @sallyyu0 so I'll go ahead and close this one now. Please feel free to re-open it or start a new issue if there's anything else you'd like to clarify!
from env_logger.
Related Issues (20)
- Add function() to Record HOT 1
- MSRV break due to is_terminal 0.4.8 HOT 1
- `WriteStyle` is ignored when used with `Target::Pipe`
- Replace is-terminal dep with std::io::IsTerminal HOT 7
- `Target::Pipe` does not auto-flush like std{out/err}
- about doc HOT 2
- Cargo.lock is not meant to be checked in for libraries HOT 4
- Trivial: the systemd example misuses RUST_LOG_STYLE HOT 1
- method not found in `&mut Formatter` HOT 1
- can't see any logs when using #[windows_subsystem = "windows"] HOT 4
- Missing changelog for 0.10.1 HOT 1
- Remove deprecated APIs
- Missing recent releases on github? HOT 1
- logger crate catches Clion stop signal HOT 1
- Provide a way to disable automatic flushing when using `Target::Pipe` HOT 1
- Feature Deprecation Without Warning or Migration HOT 3
- env_logger doesn't output anything HOT 4
- Issue with `anstream` optional dependency HOT 1
- Empty changelog for 0.11.2 HOT 1
- [feat] support star matching HOT 3
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 env_logger.