How can I disable http access logs on Strapi v4?

System Information
  • Strapi Version: 4.15.4
  • Operating System: macOS Ventura 13.5.2
  • Database: MySQL 8.0 (Docker container)
  • Node Version: 20.9.0
  • NPM Version: 10.1.0
  • Yarn Version:

Is there a way to disable http access logs appeared in console by default ? I want to disable it because when Strapi application is deployed on Cloud Run, Cloud Run logs every http access to Cloud Logging and logs generated by Strapi become redundant.

[2023-11-18 13:29:18.550] http: GET /admin/plugins/content-type-builder/content-types/create-content-type (16 ms) 200
[2023-11-18 13:29:18.676] http: GET /admin/project-type (7 ms) 200
[2023-11-18 13:29:18.738] http: POST /admin/renew-token (24 ms) 200
[2023-11-18 13:29:18.744] http: GET /admin/init (4 ms) 200
[2023-11-18 13:29:18.759] http: GET /admin/telemetry-properties (12 ms) 200
[2023-11-18 13:29:19.644] http: GET /admin/users/me (31 ms) 200
[2023-11-18 13:29:19.651] http: GET /admin/information (43 ms) 200
[2023-11-18 13:29:19.659] http: GET /admin/users/me/permissions (48 ms) 200
[2023-11-18 13:29:19.677] http: GET /i18n/locales (11 ms) 200
[2023-11-18 13:29:19.738] http: GET /content-type-builder/components (14 ms) 200
[2023-11-18 13:29:19.743] http: GET /content-type-builder/content-types (16 ms) 200
[2023-11-18 13:29:19.746] http: GET /content-type-builder/reserved-names (16 ms) 200
[2023-11-18 13:29:26.409] http: GET /content-manager/init (25 ms) 200
[2023-11-18 13:29:26.432] http: GET /content-manager/content-types-settings (17 ms) 200

I tried to disable by setting the log level to “warn” at config/logger.ts but seems like not working. (I just added the file below after the npx create-strapi-app@latest and didn’t change anything else. )

// config/logger.ts
import winston from 'winston';

export default [
  {
    transports: [
      new winston.transports.Console({
        level: 'warn',
      }),
    ],
  },
];

Is this a bug or am I missing something ?

Worked for me:

// config/logger.ts

'use strict';

const {
  winston,
  formats: { prettyPrint, levelFilter },
} = require('@strapi/logger');

module.exports = {
  transports: [
    new winston.transports.Console({
      level: 'warn',  
      format: winston.format.combine(
        levelFilter('http'),
        prettyPrint({ timestamps: 'YYYY-MM-DD hh:mm:ss.SSS' })
      ),
    }),
  ],
};

Source: Middlewares | Strapi Documentation