# App Flask, tryton log level

**URL:** https://discuss.tryton.org/t/app-flask-tryton-log-level/7896
**Category:** Developer
**Tags:** flask
**Created:** [September 26, 2024, 9:24am UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896 "2024-09-26T09:24:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pumontjm](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/bbce88/32.png) [@pumontjm](https://discuss.tryton.org/u/pumontjm)
#### Post date: [September 26, 2024, 9:24am UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896/1 "2024-09-26T09:24:22Z")

</div>

Hi,  
I am creating a flask application with flask\_tryton.  
I can’t find how to modify the tryton log level.  
How can we enter the trytond-logconf.conf file as a parameter?

```auto
app = Flask( __name__ )
app.config['TRYTON_DATABASE'] = 'base'
app.config['TRYTON_CONFIG'] = 'trytond.conf'
app.config['SECRET_KEY'] = 'keyxxxxxxxxxxxxxxxxxxx'

tryton = Tryton(app, configure_jinja=False)

...

if __name__ == " __main__":
    app.run(port=5500, debug=False)

```

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 26, 2024, 11:28am UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896/2 "2024-09-26T11:28:30Z")

</div>

When using [`trytond` as a WSGI server](https://docs.tryton.org/latest/server/topics/start_server.html#wsgi-server), you can setup using some environment variables like `TRYTOND_LOGGING_CONFIG` or `TRYTOND_LOGGING_LEVEL`.

---

<div class="post-metadata">

### Author: ![pumontjm](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/bbce88/32.png) [@pumontjm](https://discuss.tryton.org/u/pumontjm)
#### Post date: [September 26, 2024, 1:14pm UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896/3 "2024-09-26T13:14:11Z")

</div>

it doesn’t work

trytond-logconf.conf:

```auto
[formatters]
keys=simple

[handlers]
keys=rotate,console

[loggers]
keys=root

[formatter_simple]
format=%(asctime)s] %(levelname)s:%(name)s:%(message)s
datefmt=%a %b %d %H:%M:%S %Y

[handler_rotate]
class=handlers.TimedRotatingFileHandler
args=('/tmp/tryton.log', 'D', 1, 30)
formatter=simple

[handler_console]
class=StreamHandler
formatter=simple
args=(sys.stdout,)

[logger_root]
level=ERROR
handlers=rotate,console

```

To launch the application:

```auto
#!/bin/bash

export TRYTOND_LOGGING_CONFIG="/path/to/trytond-logconf.conf"
gunicorn -w 4 -b 127.0.0.1:8080 api:app

```

log content:

```auto
...
INFO:trytond.modules:asp_PartyOther
INFO:trytond.modules:asp_Product
INFO:trytond.modules:asp_Purchase
INFO:trytond.modules:asp_ImportProduct
INFO:trytond.modules:asp_Sale
INFO:trytond.pool:setup pool for "asperpgi8"
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
DEBUG:trytond.backend.postgresql.database:b'SELECT "provolatile" FROM pg_proc WHERE proname=\'unaccent\''
INFO:trytond.pool:setup mixin for "asperpgi8"
INFO:trytond.pool:setup mixin for "asperpgi8"
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
DEBUG:trytond.backend.postgresql.database:b'SELECT 1'
INFO:trytond.modules:all modules loaded
INFO:trytond.modules:all modules loaded
DEBUG:trytond.backend.postgresql.database:b'SELECT "a"."id" AS "id", "a"."create_date" AS "create_date", "a"."create_uid" AS "create_uid", "a"."hostname" AS "hostname", "a"."language" AS "language", "a"."product_price_decimal" AS "product_price_decimal", "a"."write_date" AS "write_date", "a"."write_uid" AS "write_uid", CAST(EXTRACT(\'EPOCH\' FROM COALESCE("a"."write_date", "a"."create_date")) AS VARCHAR) AS "_timestamp" FROM "ir_configuration" AS "a" WHERE true ORDER BY "a"."id" ASC LIMIT 1'
...

```

Maybe there is something to add to the code but I couldn’t find any more information ?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [September 26, 2024, 1:28pm UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896/4 "2024-09-26T13:28:25Z")

</div>

My bad with `flask-tryton`, `trytond` is not used as WSGI application.  
So you are responsible in your code to setup the [`logging` module](https://docs.python.org/3/library/logging.html).

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [October 3, 2024, 7:22am UTC](https://discuss.tryton.org/t/app-flask-tryton-log-level/7896/5 "2024-10-03T07:22:39Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
