typeorm logging

This commit is contained in:
Ulf Gebhardt 2022-01-17 10:33:38 +01:00
parent b43740967f
commit b94e59882d
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ const database = {
DB_USER: process.env.DB_USER || 'root',
DB_PASSWORD: process.env.DB_PASSWORD || '',
DB_DATABASE: process.env.DB_DATABASE || 'gradido_community',
TYPEORM_LOGGING_RELATIVE_PATH: process.env.TYPEORM_LOGGING_RELATIVE_PATH || '../deployment/bare_metal/log/typeorm.backend.log'
}
const klicktipp = {

View File

@ -1,4 +1,4 @@
import { createConnection, Connection } from 'typeorm'
import { createConnection, Connection, FileLogger } from 'typeorm'
import CONFIG from '../config'
import { entities } from '@entity/index'
@ -15,6 +15,10 @@ const connection = async (): Promise<Connection | null> => {
database: CONFIG.DB_DATABASE,
entities,
synchronize: false,
logging: true,
logger: new FileLogger("all", {
logPath: CONFIG.TYPEORM_LOGGING_RELATIVE_PATH
}),
})
} catch (error) {
// eslint-disable-next-line no-console