LukeMathWalker/tracing-actix-web

How can I write the traces into a file alongside with the logs

sagoez opened this issue · 2 comments

sagoez commented

In my terminal I find this

    log.file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/tantivy-0.20.2/src/directory/file_watcher.rs
[2023-08-16T10:11:45.378Z]  INFO: majin/95688 on Samuel-Macbook-.local: NOTICE: relation "refinery_schema_history" already exists, skipping (file=null,line=null,log.line=338,log.module_path=tokio_postgres::connection,log.target=tokio_postgres::connection,target=log)
    log.file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-postgres-0.7.8/src/connection.rs
[2023-08-16T10:11:45.384Z]  INFO: majin/95688 on Samuel-Macbook-.local: current version: 12 (file=null,line=null,log.line=52,log.module_path=refinery_core::traits,log.target=refinery_core::traits,target=log)
    log.file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/refinery-core-0.8.10/src/traits/mod.rs
[2023-08-16T10:11:45.384Z]  INFO: majin/95688 on Samuel-Macbook-.local: no migrations to apply (file=null,line=null,log.line=204,log.module_path=refinery_core::traits::r#async,log.target=refinery_core::traits::r#async,target=log)
    log.file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/refinery-core-0.8.10/src/traits/async.rs
[2023-08-16T10:11:45.384Z]  INFO: majin/95688 on Samuel-Macbook-.local: Starting server at 127.0.0.1:8080 (file=src/lib.rs,line=42,target=majin)
[2023-08-16T10:11:45.597Z]  INFO: majin/95688 on Samuel-Macbook-.local: starting 10 workers (line=200,target=actix_server::builder)
    file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-2.2.0/src/builder.rs
[2023-08-16T10:11:45.598Z]  INFO: majin/95688 on Samuel-Macbook-.local: Actix runtime found; starting in Actix runtime (line=196,target=actix_server::server)
    file: /Users/sjimenez/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-server-2.2.0/src/server.rs
[2023-08-16T10:12:07.383Z]  INFO: majin/95688 on Samuel-Macbook-.local: [HTTP REQUEST - START] (file=src/configuration/telemetry.rs,http.client_ip=127.0.0.1,http.flavor=1.1,http.host=localhost:8080,http.method=POST,http.route=/auth/register,http.scheme=http,http.target=/auth/register,http.user_agent=PostmanRuntime/7.32.3,line=129,otel.kind=server,otel.name="HTTP POST /auth/register",request_id=418337b5-2ea6-4a1d-a80b-4877c82eff55,target=majin::configuration::telemetry)
[2023-08-16T10:12:07.384Z]  INFO: majin/95688 on Samuel-Macbook-.local: [REGISTER A NEW USER - START] (email=Anais.Dickinson43@hotmail.com,file=src/http/route/auth.rs,http.client_ip=127.0.0.1,http.flavor=1.1,http.host=localhost:8080,http.method=POST,http.route=/auth/register,http.scheme=http,http.target=/auth/register,http.user_agent=PostmanRuntime/7.32.3,line=131,otel.kind=server,otel.name="HTTP POST /auth/register",request_id=418337b5-2ea6-4a1d-a80b-4877c82eff55,target=majin::http::route::auth,trace_id=9f60d4e0edb5af11fb7a7ccddb69cdad)

However in using tracing_appender I can only see the ones that say log.file. How can I write them all as I see them.

This is a question for the crates you are using as subscribers for tracing, it doesn't belong here.

Will ask there, thanks. It just so happens that it works with actixs' Logger::default but no with TracingLogger::default. That's why I asked here.