aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--config/default.yaml2
-rw-r--r--config/production.yaml.example2
-rw-r--r--server/helpers/logger.ts27
-rw-r--r--server/initializers/config.ts3
4 files changed, 23 insertions, 11 deletions
diff --git a/config/default.yaml b/config/default.yaml
index e4e2d2273..a213d5b0a 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -75,6 +75,8 @@ storage:
75 75
76log: 76log:
77 level: 'info' # debug/info/warning/error 77 level: 'info' # debug/info/warning/error
78 rotation:
79 enabled : true # Enabled by default, if disabled make sure that 'storage.logs' is pointing to a folder handled by logrotate
78 80
79search: 81search:
80 # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance 82 # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance
diff --git a/config/production.yaml.example b/config/production.yaml.example
index bd0d956bd..cdf6136d8 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -76,6 +76,8 @@ storage:
76 76
77log: 77log:
78 level: 'info' # debug/info/warning/error 78 level: 'info' # debug/info/warning/error
79 rotation:
80 enabled : true
79 81
80search: 82search:
81 # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance 83 # Add ability to fetch remote videos/actors by their URI, that may not be federated with your instance
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 734523b01..8603dd761 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -2,6 +2,7 @@
2import { mkdirpSync } from 'fs-extra' 2import { mkdirpSync } from 'fs-extra'
3import * as path from 'path' 3import * as path from 'path'
4import * as winston from 'winston' 4import * as winston from 'winston'
5import { FileTransportOptions } from 'winston/lib/winston/transports'
5import { CONFIG } from '../initializers/config' 6import { CONFIG } from '../initializers/config'
6import { omit } from 'lodash' 7import { omit } from 'lodash'
7 8
@@ -45,6 +46,21 @@ const labelFormatter = winston.format.label({
45 label 46 label
46}) 47})
47 48
49const fileLoggerOptions: FileTransportOptions = {
50
51 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'),
52 handleExceptions: true,
53 format: winston.format.combine(
54 winston.format.timestamp(),
55 jsonLoggerFormat
56 )
57}
58
59if (CONFIG.LOG.ROTATION) {
60 fileLoggerOptions.maxsize = 1024 * 1024 * 12
61 fileLoggerOptions.maxFiles = 20
62}
63
48const logger = winston.createLogger({ 64const logger = winston.createLogger({
49 level: CONFIG.LOG.LEVEL, 65 level: CONFIG.LOG.LEVEL,
50 format: winston.format.combine( 66 format: winston.format.combine(
@@ -52,16 +68,7 @@ const logger = winston.createLogger({
52 winston.format.splat() 68 winston.format.splat()
53 ), 69 ),
54 transports: [ 70 transports: [
55 new winston.transports.File({ 71 new winston.transports.File(fileLoggerOptions),
56 filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube.log'),
57 handleExceptions: true,
58 maxsize: 1024 * 1024 * 12,
59 maxFiles: 20,
60 format: winston.format.combine(
61 winston.format.timestamp(),
62 jsonLoggerFormat
63 )
64 }),
65 new winston.transports.Console({ 72 new winston.transports.Console({
66 handleExceptions: true, 73 handleExceptions: true,
67 format: winston.format.combine( 74 format: winston.format.combine(
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 2be300a57..50653b0a0 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -83,7 +83,8 @@ const CONFIG = {
83 }, 83 },
84 TRUST_PROXY: config.get<string[]>('trust_proxy'), 84 TRUST_PROXY: config.get<string[]>('trust_proxy'),
85 LOG: { 85 LOG: {
86 LEVEL: config.get<string>('log.level') 86 LEVEL: config.get<string>('log.level'),
87 ROTATION: config.get<boolean>('log.rotation.enabled')
87 }, 88 },
88 SEARCH: { 89 SEARCH: {
89 REMOTE_URI: { 90 REMOTE_URI: {