Winston not creating any output when running in a Docker container
Author: lukeberry99Created Jul 9, 2020Updated Aug 11, 2026
Please tell us about your environment:
winstonversion?-
winston@2 -
winston@3
-
node -voutputs: v14.5.0- Operating System? (Windows, macOS, or Linux) macOS + Alpine Linux
- Language? (all | TypeScript X.X | ES6/7 | ES5 | Dart) ES6/7
What is the problem?
Winston does not print any log output when running inside a Docker container, either to the Console or to a file (it does create the file, just doesn't put any output there.)
Here is my Winston config.
import winston from 'winston'
import config from '../config'
const transports = []
transports.push(
new winston.transports.Console(),
new winston.transports.File({
filename: 'test.log'
})
)
const LoggerInstance = winston.createLogger({
level: config.logs.level,
levels: winston.config.npm.levels,
format: winston.format.combine(
winston.format.timestamp({
format: 'YYYY-MM-DD HH:mm:ss'
}),
winston.format.errors({ stack: true }),
winston.format.splat(),
winston.format.json()
),
transports
})
export default LoggerInstanceThis is my Dockerfile
FROM node:current-alpine
WORKDIR /usr/src
RUN apk --no-cache add --virtual builds-deps build-base python
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install
COPY . .
ENV NODE_ENV production
CMD ["npm", "run", "start"]Here is where I'm logging
import expressLoader from './express'
import databaseLoader from './database'
import dependencyLoader from './dependencies'
import modelLoader from './models'
import Logger from './logger'
export default async ({ expressApp }) => {
const conn = databaseLoader
Logger.info('✅️ Database loaded')
try {
await conn.authenticate()
Logger.info(' ️Database connected')
} catch (e) {
Logger.error(' Error connecting to database: %o', e)
process.exit(1)
}
Logger.info('➕ Injecting dependencies')
dependencyLoader()
Logger.info('✅️ Dependencies injected')
Logger.info('➕ Injecting models')
modelLoader()
Logger.info('✅️ Models injected')
expressLoader({ app: expressApp })
Logger.info('✅️ Express loaded')
}I get the following output when running locally

And when I run from my Docker container, I get the following

If I change all of the Logger.info to console.log, I get output.
The log level (and all other config) is the same, and is currently set to silly.
Any ideas?
Source: winstonjs/winston