1

I have below issues with Express Gateway logs:

  1. I have enabled Express Gateway logs according to their documentation, but I couldn't find any log file created under my gateway root.
  2. When I start the gateway with below command it shows debug logs, but the changes that I do in gateway.config.yml config will not reflect in debug log.

    LOG_LEVEL=debug npm start

  3. How do I add timestamp for the log entries?

Edited:

gateway.config.yml config values:

pipelines: default: apiEndpoints: - api policies: - log: # policy name - action: # array of condition/actions objects #timestamp: true message: Test ${req.method} ${req.originalUrl} # parameter for log action # Uncommentkey-auth:when instructed to in the Getting Started guide. - key-auth: - proxy: - action: serviceEndpoint: httpbin changeOrigin: true

Chandra615
  • 13
  • 5

1 Answers1

4
  1. Express Gateway has no way to store logs on files. While this is technically possible (We're using Winston under the hood so we would just need to put the right transport strategy) we haven't provided a way to enable it. Right now you'd need to catch the log from the standard output and save them somewhere, using IO redirection in case you're on an UNIX system.

  2. I'm not quite sure what you mean here. When you're doing some changes to the gateway.config file you should receive an info message telling you the hot reloading has completed. If you can elaborate more I can be more precise here

  3. Unfortunately you can't. Our logging strategy is not exactly THAT configurable. It might be worth to open an issue on our repository so we can prioritize these requests.

Thanks,

V.

Vincenzo
  • 1,549
  • 1
  • 9
  • 17
  • Thanks for your response, actually what I need to achieve here is the third question I raised, adding timestamp to the log entry, for that I have added parameters to gateway.config thinking that same Winston parameters will support (e.g format) and tried out to doing hot reload as well, but nothing reflected in the log even I misspelled ${req.method} parameter to ${req.abc}, and correct method printed in the log, thats why I suspected that even I enable the logs from config, the EG itself use different one,I will update my current config in my post, can you please check if I did anything wrong – Chandra615 Aug 01 '18 at 12:45
  • No, we do not forward action parameters to the Winston logging. It's something that we should probably do. You should open an issue on our github repository – Vincenzo Aug 01 '18 at 16:04
  • But when I check your previous versions (below 1.9.1) timestamp was there: winston.loggers.add('EG:policy', { console: { level: process.env.LOG_LEVEL_POLICY || process.env.LOG_LEVEL || 'warn', colorize, **timestamp**, label: 'EG:policy' } }); – Chandra615 Aug 02 '18 at 18:54
  • That is correct, it's probably a regression due to the migration on Winston 3 – Vincenzo Aug 03 '18 at 13:59