Create custom action similar to mendix Log message action

0
Hello,  I need to extend the log structure from the basic (timestamp, level, node, message, stackTrace, hasStackTrace) with more parameters. I am using a model that Initializes the log subscriber that writes log messages to the database with the model message entity. I want to replace the mendix log message action with my custom action so the extended structure will be commit to the data base.  Is there a way to find the code for log message action? or is there any other suggestion how to extend the log structure?
asked
2 answers
1

HI Lital Sherman

  1. Create a Custom Log Message Action:

    • In your Mendix project, create a new microflow or nanoflow.
    • Add a “Log message” activity to the flow.
    • Configure the properties for the log message, including the extended parameters you want (e.g., additional fields beyond the basic ones like timestamp, level, node, message, stackTrace, and hasStackTrace).
  2. Customize the Log Message:

    • In the “Log message” activity, you can set the log level, message content, and any additional parameters you need.
    • You can use expressions to populate the extended fields with dynamic values.
  3. Replace Default Log Message Action:

    • Find all occurrences of the default Mendix log message action in your project.
    • Replace them with your custom log message action.
  4. Commit to the Database:

    • In your custom log message action, ensure that the extended log structure is committed to the database.
    • You can use Mendix’s built-in database actions (e.g., “Create object” or “Change object”) to save the log data.
  5. Testing and Validation:

    • Test your custom log message action thoroughly to ensure it works as expected.
    • Verify that the extended log structure is correctly stored in the database.

Finding the Code for the Default Log Message Action:

Other Suggestions for Extending the Log Structure:

  • If you need more flexibility or want to handle logging differently, consider using a custom Java action to log messages. This allows you to directly write Java code for logging.
  • You can create a custom Java action that accepts parameters (including the extended fields) and handles the database commit logic.

Remember to thoroughly test your custom solution and ensure it aligns with your project requirements. Good luck! 😊🚀

answered
0

Wow, thank you very much for the detailed answer.

It's very helpful!

answered